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')