8 from .subtitles import SubtitlesInfoExtractor
11 class VikiIE(SubtitlesInfoExtractor):
14 _VALID_URL = r'^https?://(?:www\.)?viki\.com/videos/(?P<id>[0-9]+v)'
16 u'url': u'http://www.viki.com/videos/1023585v-heirs-episode-14',
17 u'file': u'1023585v.mp4',
18 u'md5': u'a21454021c2646f5433514177e2caa5f',
20 u'title': u'Heirs Episode 14',
22 u'description': u'md5:c4b17b9626dd4b143dcc4d855ba3474e',
23 u'upload_date': u'20131121',
26 u'skip': u'Blocked in the US',
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group(1)
33 webpage = self._download_webpage(url, video_id)
34 title = self._og_search_title(webpage)
35 description = self._og_search_description(webpage)
36 thumbnail = self._og_search_thumbnail(webpage)
38 uploader_m = re.search(
39 r'<strong>Broadcast Network: </strong>\s*([^<]*)<', webpage)
40 if uploader_m is None:
43 uploader = uploader_m.group(1).strip()
45 rating_str = self._html_search_regex(
46 r'<strong>Rating: </strong>\s*([^<]*)<', webpage,
47 u'rating information', default='').strip()
55 age_limit = RATINGS.get(rating_str)
57 info_url = 'http://www.viki.com/player5_fragment/%s?action=show&controller=videos' % video_id
58 info_webpage = self._download_webpage(
59 info_url, video_id, note=u'Downloading info page')
60 if re.match(r'\s*<div\s+class="video-error', info_webpage):
62 u'Video %s is blocked from your location.' % video_id,
64 video_url = self._html_search_regex(
65 r'<source[^>]+src="([^"]+)"', info_webpage, u'video URL')
67 upload_date_str = self._html_search_regex(
68 r'"created_at":"([^"]+)"', info_webpage, u'upload date')
70 unified_strdate(upload_date_str)
71 if upload_date_str is not None
76 video_subtitles = self.extract_subtitles(video_id, info_webpage)
77 if self._downloader.params.get('listsubtitles', False):
78 self._list_available_subtitles(video_id, info_webpage)
85 'description': description,
86 'thumbnail': thumbnail,
87 'age_limit': age_limit,
89 'subtitles': video_subtitles,
90 'upload_date': upload_date,
93 def _get_available_subtitles(self, video_id, info_webpage):
95 for sturl_html in re.findall(r'<track src="([^"]+)"/>', info_webpage):
96 sturl = unescapeHTML(sturl_html)
97 m = re.search(r'/(?P<lang>[a-z]+)\.vtt', sturl)
100 res[m.group('lang')] = sturl