7 from .subtitles import SubtitlesInfoExtractor
10 class VikiIE(SubtitlesInfoExtractor):
13 _VALID_URL = r'^https?://(?:www\.)?viki\.com/videos/(?P<id>[0-9]+v)'
15 u'url': u'http://www.viki.com/videos/1023585v-heirs-episode-14',
16 u'file': u'1023585v.mp4',
17 u'md5': u'a21454021c2646f5433514177e2caa5f',
19 u'title': u'Heirs Episode 14',
21 u'description': u'md5:c4b17b9626dd4b143dcc4d855ba3474e',
22 u'upload_date': u'20131121',
25 u'skip': u'Blocked in the US',
28 def _real_extract(self, url):
29 mobj = re.match(self._VALID_URL, url)
30 video_id = mobj.group(1)
32 webpage = self._download_webpage(url, video_id)
33 title = self._og_search_title(webpage)
34 description = self._og_search_description(webpage)
35 thumbnail = self._og_search_thumbnail(webpage)
37 uploader = self._html_search_regex(
38 r'<strong>Broadcast Network: </strong>\s*([^<]*)<', webpage,
40 if uploader is not None:
41 uploader = uploader.strip()
43 rating_str = self._html_search_regex(
44 r'<strong>Rating: </strong>\s*([^<]*)<', webpage,
45 u'rating information', default='').strip()
53 age_limit = RATINGS.get(rating_str)
55 info_url = 'http://www.viki.com/player5_fragment/%s?action=show&controller=videos' % video_id
56 info_webpage = self._download_webpage(
57 info_url, video_id, note=u'Downloading info page')
58 if re.match(r'\s*<div\s+class="video-error', info_webpage):
60 u'Video %s is blocked from your location.' % video_id,
62 video_url = self._html_search_regex(
63 r'<source[^>]+src="([^"]+)"', info_webpage, u'video URL')
65 upload_date_str = self._html_search_regex(
66 r'"created_at":"([^"]+)"', info_webpage, u'upload date')
68 unified_strdate(upload_date_str)
69 if upload_date_str is not None
74 video_subtitles = self.extract_subtitles(video_id, info_webpage)
75 if self._downloader.params.get('listsubtitles', False):
76 self._list_available_subtitles(video_id, info_webpage)
83 'description': description,
84 'thumbnail': thumbnail,
85 'age_limit': age_limit,
87 'subtitles': video_subtitles,
88 'upload_date': upload_date,
91 def _get_available_subtitles(self, video_id, info_webpage):
93 for sturl in re.findall(r'<track src="([^"]+)"/>'):
94 m = re.search(r'/(?P<lang>[a-z]+)\.vtt', sturl)
97 res[m.group('lang')] = sturl