]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tudou.py
Fix description of the modularization.
[youtubedl] / youtube_dl / extractor / tudou.py
1 import re
2
3 from .common import InfoExtractor
4
5
6 class TudouIE(InfoExtractor):
7 _VALID_URL = r'(?:http://)?(?:www\.)?tudou\.com/(?:listplay|programs)/(?:view|(.+?))/(?:([^/]+)|([^/]+)\.html)'
8
9 def _real_extract(self, url):
10 mobj = re.match(self._VALID_URL, url)
11 video_id = mobj.group(2).replace('.html','')
12 webpage = self._download_webpage(url, video_id)
13 video_id = re.search('"k":(.+?),',webpage).group(1)
14 title = re.search(",kw:\"(.+)\"",webpage)
15 if title is None:
16 title = re.search(",kw: \'(.+)\'",webpage)
17 title = title.group(1)
18 thumbnail_url = re.search(",pic: \'(.+?)\'",webpage)
19 if thumbnail_url is None:
20 thumbnail_url = re.search(",pic:\"(.+?)\"",webpage)
21 thumbnail_url = thumbnail_url.group(1)
22 info_url = "http://v2.tudou.com/f?id="+str(video_id)
23 webpage = self._download_webpage(info_url, video_id, "Opening the info webpage")
24 final_url = re.search('\>(.+?)\<\/f\>',webpage).group(1)
25 ext = (final_url.split('?')[0]).split('.')[-1]
26 return [{
27 'id': video_id,
28 'url': final_url,
29 'ext': ext,
30 'title': title,
31 'thumbnail': thumbnail_url,
32 }]