]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/tudou.py
6 from .common
import InfoExtractor
9 class TudouIE(InfoExtractor
):
10 _VALID_URL
= r
'(?:http://)?(?:www\.)?tudou\.com/(?:listplay|programs|albumplay)/(?:view|(.+?))/(?:([^/]+)|([^/]+))(?:\.html)?'
12 u
'url': u
'http://www.tudou.com/listplay/zzdE77v6Mmo/2xN2duXMxmw.html',
13 u
'file': u
'159448201.f4v',
14 u
'md5': u
'140a49ed444bd22f93330985d8475fcb',
16 u
"title": u
"卡马乔国足开大脚长传冲吊集锦"
20 u
'url': u
'http://www.tudou.com/albumplay/TenTw_JgiPM/PzsAs5usU9A.html',
24 u
'title': u
'todo.mp4',
26 u
'add_ie': [u
'Youku'],
27 u
'skip': u
'Only works from China'
30 def _url_for_id(self
, id, quality
= None):
31 info_url
= "http://v2.tudou.com/f?id="+str(id)
33 info_url
+= '&hd' + quality
34 webpage
= self
._download
_webpage
(info_url
, id, "Opening the info webpage")
35 final_url
= self
._html
_search
_regex
('>(.+?)</f>',webpage
, 'video url')
38 def _real_extract(self
, url
):
39 mobj
= re
.match(self
._VALID
_URL
, url
)
40 video_id
= mobj
.group(2)
41 webpage
= self
._download
_webpage
(url
, video_id
)
43 m
= re
.search(r
'vcode:\s*[\'"](.+?)[\'"]', webpage)
47 'url
': u'youku
:' + m.group(1),
51 title = self._search_regex(r",kw:['\"](.+?
)[\"']", webpage, u'title
')
52 thumbnail_url = self._search_regex(
53 r",pic:\s*[\"'](.+?
)[\"']", webpage, u'thumbnail URL
', fatal=False)
55 segs_json = self._search_regex(r'segs
: \'(.*)\'', webpage, 'segments
')
56 segments = json.loads(segs_json)
57 # It looks like the keys are the arguments that have to be passed as
58 # the hd field in the request url, we pick the higher
59 quality = sorted(segments.keys())[-1]
60 parts = segments[quality]
62 len_parts = len(parts)
64 self.to_screen(u'%s: found
%s parts
' % (video_id, len_parts))
67 final_url = self._url_for_id(part_id, quality)
68 ext = (final_url.split('?
')[0]).split('.')[-1]
69 part_info = {'id': part_id,
73 'thumbnail
': thumbnail_url,
75 result.append(part_info)