From 92490d35ee83b19104eef3f97a156b5c1eca7e80 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 14 Apr 2013 17:32:23 +0200 Subject: [PATCH 1/6] QQ: dirty fix #153 --- src/you_get/downloader/bilibili.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/downloader/bilibili.py b/src/you_get/downloader/bilibili.py index e8fa639f..832cd0c4 100644 --- a/src/you_get/downloader/bilibili.py +++ b/src/you_get/downloader/bilibili.py @@ -55,7 +55,7 @@ def parse_cid_playurl(xml): def bilibili_download_by_cid(id, title, output_dir = '.', merge = True, info_only = False): url = 'http://interface.bilibili.tv/playurl?cid=' + id - urls = parse_cid_playurl(get_html(url, 'utf-8')) + urls = [i if not re.match(r'.*\.qqvideo\.tc\.qq\.com', i) else re.sub(r'.*\.qqvideo\.tc\.qq\.com', 'http://vsrc.store.qq.com', i) for i in parse_cid_playurl(get_html(url, 'utf-8'))] # dirty fix for QQ if re.search(r'\.(flv|hlv)\b', urls[0]): type = 'flv' From 3a3dd740f568cfc154e2aba9b0e6ea16fcb39923 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 14 Apr 2013 18:02:01 +0200 Subject: [PATCH 2/6] Acfun & Bilibili: fix #148 --- src/you_get/downloader/acfun.py | 2 +- src/you_get/downloader/bilibili.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/you_get/downloader/acfun.py b/src/you_get/downloader/acfun.py index 79eb1b4c..aa880bee 100644 --- a/src/you_get/downloader/acfun.py +++ b/src/you_get/downloader/acfun.py @@ -33,7 +33,7 @@ def acfun_download_by_id(id, title = None, output_dir = '.', merge = True, info_ if not info_only: print('Downloading %s ...' % (title + '.cmt.json')) cmt = get_srt_json(vid) - with open(title + '.cmt.json', 'w') as x: + with open(os.path.join(output_dir, title + '.cmt.json'), 'w') as x: x.write(cmt) def acfun_download(url, output_dir = '.', merge = True, info_only = False): diff --git a/src/you_get/downloader/bilibili.py b/src/you_get/downloader/bilibili.py index 832cd0c4..20e3c467 100644 --- a/src/you_get/downloader/bilibili.py +++ b/src/you_get/downloader/bilibili.py @@ -101,7 +101,7 @@ def bilibili_download(url, output_dir = '.', merge = True, info_only = False): if not info_only: print('Downloading %s ...' % (title + '.cmt.xml')) xml = get_srt_xml(id) - with open(title + '.cmt.xml', 'w') as x: + with open(os.path.join(output_dir, title + '.cmt.xml'), 'w') as x: x.write(xml) site_info = "bilibili.tv" From f0a21e8ea548ce428560a02cc805d7ac7548c982 Mon Sep 17 00:00:00 2001 From: "zhuhuotui[codepongo]" Date: Thu, 11 Apr 2013 10:12:40 +0800 Subject: [PATCH 3/6] add suport for songtaste --- .gitignore | 4 +++ src/you_get/__main__.py | 1 + src/you_get/downloader/__init__.py | 1 + src/you_get/downloader/songtaste.py | 44 +++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 src/you_get/downloader/songtaste.py diff --git a/.gitignore b/.gitignore index 4db9faa4..63b93fe6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,7 @@ _*/ *.mpg *.ts *.webm + +*.DS_Store +*.swp +*~ diff --git a/src/you_get/__main__.py b/src/you_get/__main__.py index e9154315..6733baea 100644 --- a/src/you_get/__main__.py +++ b/src/you_get/__main__.py @@ -57,6 +57,7 @@ def url_to_module(url): 'youku': youku, 'youtu': youtube, 'youtube': youtube, + 'songtaste':songtaste, #TODO } if k in downloads: diff --git a/src/you_get/downloader/__init__.py b/src/you_get/downloader/__init__.py index b0c0115f..11fa7b77 100644 --- a/src/you_get/downloader/__init__.py +++ b/src/you_get/downloader/__init__.py @@ -35,3 +35,4 @@ from .baidu import * from .yinyuetai import * from .youku import * from .youtube import * +from .songtaste import * diff --git a/src/you_get/downloader/songtaste.py b/src/you_get/downloader/songtaste.py new file mode 100644 index 00000000..7deae03a --- /dev/null +++ b/src/you_get/downloader/songtaste.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +__all__ = ['songtaste_download'] + +from ..common import * +import urllib.error +def songtaste_download(url, output_dir = '.', merge = True, info_only = False): + + if re.match(r'http://www.songtaste.com/song/\d+', url): + old_fake_headers = fake_headers + id = r1(r'http://www.songtaste.com/song/(\d+)', url) + player_url = 'http://www.songtaste.com/playmusic.php?song_id='+str(id) + fake_headers['Referer'] = player_url + html = get_response(player_url).data + r = '''^WrtSongLine\((.*)\)''' + + reg = re.compile(r , re.M) + + m = reg.findall(html.decode('gbk')) + l = m[0].replace('"', '').replace(' ', '').split(',') + + title = l[2] + '-' + l[1] + + for i in range(0, 10): + real_url = l[5].replace('http://mg', 'http://m%d' % i) + try: + type, ext, size = url_info(real_url, True) + except urllib.error.HTTPError as e: + if 403 == e.code: + continue + else: + raise e + break + + print_info(site_info, title, type, size) + + if not info_only: + download_urls([real_url], title, ext, size, output_dir, refer = url, merge = merge, faker = True) + fake_hreaders = old_fake_headers + + +site_info = "www.songtaste.com" +download = songtaste_download +download_playlist = playlist_not_supported('songtaste') From d5ba59af6c5e1b337b0b9a0471f0948a87da1ecc Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 14 Apr 2013 18:17:52 +0200 Subject: [PATCH 4/6] fix trailing whitespace errors --- src/you_get/downloader/songtaste.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/you_get/downloader/songtaste.py b/src/you_get/downloader/songtaste.py index 7deae03a..687af394 100644 --- a/src/you_get/downloader/songtaste.py +++ b/src/you_get/downloader/songtaste.py @@ -4,8 +4,8 @@ __all__ = ['songtaste_download'] from ..common import * import urllib.error -def songtaste_download(url, output_dir = '.', merge = True, info_only = False): +def songtaste_download(url, output_dir = '.', merge = True, info_only = False): if re.match(r'http://www.songtaste.com/song/\d+', url): old_fake_headers = fake_headers id = r1(r'http://www.songtaste.com/song/(\d+)', url) @@ -13,12 +13,12 @@ def songtaste_download(url, output_dir = '.', merge = True, info_only = False): fake_headers['Referer'] = player_url html = get_response(player_url).data r = '''^WrtSongLine\((.*)\)''' - + reg = re.compile(r , re.M) - + m = reg.findall(html.decode('gbk')) l = m[0].replace('"', '').replace(' ', '').split(',') - + title = l[2] + '-' + l[1] for i in range(0, 10): @@ -33,12 +33,11 @@ def songtaste_download(url, output_dir = '.', merge = True, info_only = False): break print_info(site_info, title, type, size) - + if not info_only: download_urls([real_url], title, ext, size, output_dir, refer = url, merge = merge, faker = True) fake_hreaders = old_fake_headers - site_info = "www.songtaste.com" download = songtaste_download download_playlist = playlist_not_supported('songtaste') From b5999e3f0d815749005499e236ba3c400ea99cc5 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 14 Apr 2013 18:19:27 +0200 Subject: [PATCH 5/6] keep things in alphabet order --- src/you_get/__main__.py | 4 ++-- src/you_get/downloader/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/you_get/__main__.py b/src/you_get/__main__.py index 6733baea..cd35a477 100644 --- a/src/you_get/__main__.py +++ b/src/you_get/__main__.py @@ -21,6 +21,7 @@ def url_to_module(url): '163': netease, '56': w56, 'acfun': acfun, + 'baidu': baidu, 'bilibili': bilibili, 'blip': blip, 'cntv': cntv, @@ -45,6 +46,7 @@ def url_to_module(url): 'sina': sina, 'smgbb': bilibili, 'sohu': sohu, + 'songtaste':songtaste, 'soundcloud': soundcloud, 'tudou': tudou, 'tumblr': tumblr, @@ -52,12 +54,10 @@ def url_to_module(url): 'vimeo': vimeo, 'vine': vine, 'xiami': xiami, - 'baidu': baidu, 'yinyuetai': yinyuetai, 'youku': youku, 'youtu': youtube, 'youtube': youtube, - 'songtaste':songtaste, #TODO } if k in downloads: diff --git a/src/you_get/downloader/__init__.py b/src/you_get/downloader/__init__.py index 11fa7b77..36b097b7 100644 --- a/src/you_get/downloader/__init__.py +++ b/src/you_get/downloader/__init__.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from .acfun import * +from .baidu import * from .bilibili import * from .blip import * from .cntv import * @@ -23,6 +24,7 @@ from .pptv import * from .qq import * from .sina import * from .sohu import * +from .songtaste import * from .soundcloud import * from .tudou import * from .tumblr import * @@ -31,8 +33,6 @@ from .vimeo import * from .vine import * from .w56 import * from .xiami import * -from .baidu import * from .yinyuetai import * from .youku import * from .youtube import * -from .songtaste import * From 96e3aea4ce8a481ac7b406c20ddd6a9a273b5457 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 14 Apr 2013 18:29:08 +0200 Subject: [PATCH 6/6] add SongTaste to README --- README.md | 3 ++- README.txt | 1 + src/you_get/downloader/songtaste.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6983b5b5..ceaabd42 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Fork me on GitHub: * 56 (56网) * Xiami (虾米) * Baidu (百度音乐) +* SongTaste ## Dependencies @@ -261,7 +262,7 @@ You-Get基于优酷下载脚本[iambus/youku-lixian](https://github.com/iambus/y * 56网 * 虾米 * 百度音乐 - +* SongTaste ## 依赖 diff --git a/README.txt b/README.txt index 5df26fe4..487c34b0 100644 --- a/README.txt +++ b/README.txt @@ -50,6 +50,7 @@ Supported Sites (As of Now) * 56 (56网) http://www.56.com * Xiami (虾米) http://www.xiami.com * Baidu (百度音乐) http://music.baidu.com +* SongTaste http://www.songtaste.com Dependencies ------------ diff --git a/src/you_get/downloader/songtaste.py b/src/you_get/downloader/songtaste.py index 687af394..1cdd0995 100644 --- a/src/you_get/downloader/songtaste.py +++ b/src/you_get/downloader/songtaste.py @@ -38,6 +38,6 @@ def songtaste_download(url, output_dir = '.', merge = True, info_only = False): download_urls([real_url], title, ext, size, output_dir, refer = url, merge = merge, faker = True) fake_hreaders = old_fake_headers -site_info = "www.songtaste.com" +site_info = "SongTaste.com" download = songtaste_download download_playlist = playlist_not_supported('songtaste')