]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/viki.py
1 from __future__
import unicode_literals
11 from .subtitles
import SubtitlesInfoExtractor
14 class VikiIE(SubtitlesInfoExtractor
):
17 _VALID_URL
= r
'^https?://(?:www\.)?viki\.com/videos/(?P<id>[0-9]+v)'
19 'url': 'http://www.viki.com/videos/1023585v-heirs-episode-14',
23 'title': 'Heirs Episode 14',
25 'description': 'md5:c4b17b9626dd4b143dcc4d855ba3474e',
26 'upload_date': '20131121',
29 'skip': 'Blocked in the US',
32 def _real_extract(self
, url
):
33 video_id
= self
._match
_id
(url
)
35 webpage
= self
._download
_webpage
(url
, video_id
)
36 title
= self
._og
_search
_title
(webpage
)
37 description
= self
._og
_search
_description
(webpage
)
38 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
40 uploader_m
= re
.search(
41 r
'<strong>Broadcast Network: </strong>\s*([^<]*)<', webpage
)
42 if uploader_m
is None:
45 uploader
= uploader_m
.group(1).strip()
47 rating_str
= self
._html
_search
_regex
(
48 r
'<strong>Rating: </strong>\s*([^<]*)<', webpage
,
49 'rating information', default
='').strip()
50 age_limit
= US_RATINGS
.get(rating_str
)
52 info_url
= 'http://www.viki.com/player5_fragment/%s?action=show&controller=videos' % video_id
53 info_webpage
= self
._download
_webpage
(
54 info_url
, video_id
, note
='Downloading info page')
55 if re
.match(r
'\s*<div\s+class="video-error', info_webpage
):
57 'Video %s is blocked from your location.' % video_id
,
59 video_url
= self
._html
_search
_regex
(
60 r
'<source[^>]+src="([^"]+)"', info_webpage
, 'video URL')
62 upload_date_str
= self
._html
_search
_regex
(
63 r
'"created_at":"([^"]+)"', info_webpage
, 'upload date')
65 unified_strdate(upload_date_str
)
66 if upload_date_str
is not None
71 video_subtitles
= self
.extract_subtitles(video_id
, info_webpage
)
72 if self
._downloader
.params
.get('listsubtitles', False):
73 self
._list
_available
_subtitles
(video_id
, info_webpage
)
80 'description': description
,
81 'thumbnail': thumbnail
,
82 'age_limit': age_limit
,
84 'subtitles': video_subtitles
,
85 'upload_date': upload_date
,
88 def _get_available_subtitles(self
, video_id
, info_webpage
):
90 for sturl_html
in re
.findall(r
'<track src="([^"]+)"/>', info_webpage
):
91 sturl
= unescapeHTML(sturl_html
)
92 m
= re
.search(r
'/(?P<lang>[a-z]+)\.vtt', sturl
)
95 res
[m
.group('lang')] = sturl