From cd1498f82d910d861a695b2f3909accd65bfaef2 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sat, 23 Feb 2013 19:43:52 +0100 Subject: [PATCH] add support for Douban, fix #112 --- README.md | 4 +++- README.txt | 1 + src/you_get/__main__.py | 1 + src/you_get/downloader/__init__.py | 1 + src/you_get/downloader/douban.py | 25 +++++++++++++++++++++++++ tests/test.py | 6 ++++++ 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/you_get/downloader/douban.py diff --git a/README.md b/README.md index 659b06d1..2859ac59 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Fork me on GitHub: * AcFun * bilibili * CNTV (中国网络电视台) +* Douban (豆瓣) * ifeng (凤凰视频) * iQIYI (爱奇艺) * Joy.cn (激动网) @@ -203,7 +204,7 @@ You-Get基于优酷下载脚本[iambus/youku-lixian](https://github.com/iambus/y ### 支持的站点(截至目前) -已实现对以下视频站点的支持,以后会陆续增加(・∀・) +已实现对以下站点的支持,以后会陆续增加(・∀・) * YouTube * Vimeo @@ -221,6 +222,7 @@ You-Get基于优酷下载脚本[iambus/youku-lixian](https://github.com/iambus/y * AcFun * bilibili * CNTV +* 豆瓣 * 凤凰视频 * 爱奇艺 * 激动网 diff --git a/README.txt b/README.txt index 3797efee..8433dfe9 100644 --- a/README.txt +++ b/README.txt @@ -29,6 +29,7 @@ Supported Sites (As of Now) * AcFun http://www.acfun.tv * bilibili http://www.bilibili.tv * CNTV (中国网络电视台) http://www.cntv.cn +* Douban (豆瓣) http://douban.com * ifeng (凤凰视频) http://v.ifeng.com * iQIYI (爱奇艺) http://www.iqiyi.com * Joy.cn (激动网) http://www.joy.cn diff --git a/src/you_get/__main__.py b/src/you_get/__main__.py index 8521747e..77889ae0 100644 --- a/src/you_get/__main__.py +++ b/src/you_get/__main__.py @@ -24,6 +24,7 @@ def url_to_module(url): 'bilibili': bilibili, 'cntv': cntv, 'dailymotion': dailymotion, + 'douban': douban, 'facebook': facebook, 'google': googleplus, 'iask': sina, diff --git a/src/you_get/downloader/__init__.py b/src/you_get/downloader/__init__.py index 64a7e08c..3855cb6a 100644 --- a/src/you_get/downloader/__init__.py +++ b/src/you_get/downloader/__init__.py @@ -4,6 +4,7 @@ from .acfun import * from .bilibili import * from .cntv import * from .dailymotion import * +from .douban import * from .facebook import * from .googleplus import * from .ifeng import * diff --git a/src/you_get/downloader/douban.py b/src/you_get/downloader/douban.py new file mode 100644 index 00000000..e27a3518 --- /dev/null +++ b/src/you_get/downloader/douban.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +__all__ = ['douban_download'] + +from ..common import * + +def douban_download(url, output_dir = '.', merge = True, info_only = False): + html = get_html(url) + + titles = re.findall(r'"name":"([^"]*)"', html) + real_urls = [re.sub('\\\\/', '/', i) for i in re.findall(r'"rawUrl":"([^"]*)"', html)] + + for i in range(len(titles)): + title = titles[i] + real_url = real_urls[i] + + type, ext, size = url_info(real_url) + + print_info(site_info, title, type, size) + if not info_only: + download_urls([real_url], title, ext, size, output_dir, merge = merge) + +site_info = "Douban.com" +download = douban_download +download_playlist = playlist_not_supported('douban') diff --git a/tests/test.py b/tests/test.py index e77d83d9..f36521ee 100644 --- a/tests/test.py +++ b/tests/test.py @@ -33,6 +33,12 @@ class YouGetTests(unittest.TestCase): ]: url_to_module(url).download(url, info_only = True) + def test_douban(self): + for url in [ + "http://site.douban.com/caofang/", + ]: + url_to_module(url).download(url, info_only = True) + def test_xiami(self): for url in [ "http://www.xiami.com/song/1769835121",