]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/viki.py
1 from __future__
import unicode_literals
5 from ..compat
import compat_urlparse
12 from .common
import InfoExtractor
15 class VikiIE(InfoExtractor
):
18 _VALID_URL
= r
'^https?://(?:www\.)?viki\.com/videos/(?P<id>[0-9]+v)'
20 'url': 'http://www.viki.com/videos/1023585v-heirs-episode-14',
24 'title': 'Heirs Episode 14',
26 'description': 'md5:c4b17b9626dd4b143dcc4d855ba3474e',
27 'upload_date': '20131121',
30 'skip': 'Blocked in the US',
33 def _real_extract(self
, url
):
34 video_id
= self
._match
_id
(url
)
36 webpage
= self
._download
_webpage
(url
, video_id
)
37 title
= self
._og
_search
_title
(webpage
)
38 description
= self
._og
_search
_description
(webpage
)
39 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
41 uploader_m
= re
.search(
42 r
'<strong>Broadcast Network: </strong>\s*([^<]*)<', webpage
)
43 if uploader_m
is None:
46 uploader
= uploader_m
.group(1).strip()
48 rating_str
= self
._html
_search
_regex
(
49 r
'<strong>Rating: </strong>\s*([^<]*)<', webpage
,
50 'rating information', default
='').strip()
51 age_limit
= US_RATINGS
.get(rating_str
)
53 info_url
= 'http://www.viki.com/player5_fragment/%s?action=show&controller=videos' % video_id
54 info_webpage
= self
._download
_webpage
(
55 info_url
, video_id
, note
='Downloading info page')
56 if re
.match(r
'\s*<div\s+class="video-error', info_webpage
):
58 'Video %s is blocked from your location.' % video_id
,
60 video_url
= self
._html
_search
_regex
(
61 r
'<source[^>]+src="([^"]+)"', info_webpage
, 'video URL')
63 upload_date_str
= self
._html
_search
_regex
(
64 r
'"created_at":"([^"]+)"', info_webpage
, 'upload date')
66 unified_strdate(upload_date_str
)
67 if upload_date_str
is not None
72 video_subtitles
= self
.extract_subtitles(video_id
, info_webpage
)
78 'description': description
,
79 'thumbnail': thumbnail
,
80 'age_limit': age_limit
,
82 'subtitles': video_subtitles
,
83 'upload_date': upload_date
,
86 def _get_subtitles(self
, video_id
, info_webpage
):
88 for sturl_html
in re
.findall(r
'<track src="([^"]+)"', info_webpage
):
89 sturl
= unescapeHTML(sturl_html
)
90 m
= re
.search(r
'/(?P<lang>[a-z]+)\.vtt', sturl
)
93 res
[m
.group('lang')] = [{
94 'url': compat_urlparse
.urljoin('http://www.viki.com', sturl
),