diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2013-06-25 21:09:15 +0200 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2013-06-25 21:09:15 +0200 |
commit | d746cd88c214338deb79cec25b597b3ef0732b5c (patch) | |
tree | f68507596c411a9d34306809febf1cf48b913451 | |
parent | 9c42603b5a453b66aa82c5d8e00da1a5df027f04 (diff) | |
parent | f4daa18152ae253bab89e1a5aaf1cdc44bede5a4 (diff) |
Merge remote-tracking branch 'yasoob/master'
-rw-r--r-- | test/tests.json | 9 | ||||
-rw-r--r-- | youtube_dl/extractor/__init__.py | 2 | ||||
-rw-r--r-- | youtube_dl/extractor/tudou.py | 32 |
3 files changed, 43 insertions, 0 deletions
diff --git a/test/tests.json b/test/tests.json index f6a70f153..5f4f642e8 100644 --- a/test/tests.json +++ b/test/tests.json @@ -686,5 +686,14 @@ "upload_date": "20130624", "uploader": "Hurts" } + }, + { + "name": "Tudou", + "url": "http://www.tudou.com/listplay/zzdE77v6Mmo/2xN2duXMxmw.html", + "file": "159447792.f4v", + "md5": "ad7c358a01541e926a1e413612c6b10a", + "info_dict": { + "title": "卡马乔国足开大脚长传冲吊集锦" + } } ] diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 7b291f907..fdfb1b4ee 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -58,6 +58,7 @@ from .youku import YoukuIE from .youporn import YouPornIE from .youtube import YoutubeIE, YoutubePlaylistIE, YoutubeSearchIE, YoutubeUserIE, YoutubeChannelIE from .zdf import ZDFIE +from .tudou import TudouIE def gen_extractors(): """ Return a list of an instance of every supported extractor. @@ -129,6 +130,7 @@ def gen_extractors(): BreakIE(), VevoIE(), JukeboxIE(), + TudouIE(), GenericIE() ] diff --git a/youtube_dl/extractor/tudou.py b/youtube_dl/extractor/tudou.py new file mode 100644 index 000000000..9ca860ab0 --- /dev/null +++ b/youtube_dl/extractor/tudou.py @@ -0,0 +1,32 @@ +import re + +from .common import InfoExtractor + + +class TudouIE(InfoExtractor): + _VALID_URL = r'(?:http://)?(?:www\.)?tudou\.com/(?:listplay|programs)/(?:view|(.+?))/(?:([^/]+)|([^/]+)\.html)' + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group(2).replace('.html','') + webpage = self._download_webpage(url, video_id) + video_id = re.search('"k":(.+?),',webpage).group(1) + title = re.search(",kw:\"(.+)\"",webpage) + if title is None: + title = re.search(",kw: \'(.+)\'",webpage) + title = title.group(1) + thumbnail_url = re.search(",pic: \'(.+?)\'",webpage) + if thumbnail_url is None: + thumbnail_url = re.search(",pic:\"(.+?)\"",webpage) + thumbnail_url = thumbnail_url.group(1) + info_url = "http://v2.tudou.com/f?id="+str(video_id) + webpage = self._download_webpage(info_url, video_id, "Opening the info webpage") + final_url = re.search('\>(.+?)\<\/f\>',webpage).group(1) + ext = (final_url.split('?')[0]).split('.')[-1] + return [{ + 'id': video_id, + 'url': final_url, + 'ext': ext, + 'title': title, + 'thumbnail': thumbnail_url, + }] |