[subtitles] Added tests to check correct behavior when no subtitles are
[youtube-dl] / youtube_dl / extractor / statigram.py
1 import re
2
3 from .common import InfoExtractor
4
5 class StatigramIE(InfoExtractor):
6     _VALID_URL = r'(?:http://)?(?:www\.)?statigr\.am/p/([^/]+)'
7     _TEST = {
8         u'url': u'http://statigr.am/p/484091715184808010_284179915',
9         u'file': u'484091715184808010_284179915.mp4',
10         u'md5': u'deda4ff333abe2e118740321e992605b',
11         u'info_dict': {
12             u"uploader_id": u"videoseconds", 
13             u"title": u"Instagram photo by @videoseconds"
14         }
15     }
16
17     def _real_extract(self, url):
18         mobj = re.match(self._VALID_URL, url)
19         video_id = mobj.group(1)
20         webpage = self._download_webpage(url, video_id)
21         html_title = self._html_search_regex(
22             r'<title>(.+?)</title>',
23             webpage, u'title')
24         title = re.sub(r'(?: *\(Videos?\))? \| Statigram$', '', html_title)
25         uploader_id = self._html_search_regex(
26             r'@([^ ]+)', title, u'uploader name', fatal=False)
27         ext = 'mp4'
28
29         return [{
30             'id':        video_id,
31             'url':       self._og_search_video_url(webpage),
32             'ext':       ext,
33             'title':     title,
34             'thumbnail': self._og_search_thumbnail(webpage),
35             'uploader_id' : uploader_id
36         }]