diff --git a/README.md b/README.md index b95d900b..2d976e56 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Fork me on GitHub: * Sina (新浪视频) * Sohu (搜狐视频) * 56 (56网) -* Xiam (虾米) +* Xiami (虾米) ## Dependencies diff --git a/README.txt b/README.txt index 13d71710..5c3a1da2 100644 --- a/README.txt +++ b/README.txt @@ -33,7 +33,7 @@ Supported Sites (As of Now) * Sina (新浪视频) http://video.sina.com.cn * Sohu (搜狐视频) http://tv.sohu.com * 56 (56网) http://www.56.com -* Xiam (虾米) http://www.xiami.com +* Xiami (虾米) http://www.xiami.com Dependencies ------------ diff --git a/you_get/downloader/xiami.py b/you_get/downloader/xiami.py index 24d97dac..852562c9 100644 --- a/you_get/downloader/xiami.py +++ b/you_get/downloader/xiami.py @@ -13,7 +13,7 @@ def location_dec(str): str = str[1:] rows = head cols = int(len(str)/rows) + 1 - + out = "" full_row = len(str) % head for c in range(cols): @@ -35,8 +35,11 @@ def xiami_download_song(sid, output_dir = '.', merge = True, info_only = False): album_name = i.getElementsByTagName("album_name")[0].firstChild.nodeValue song_title = i.getElementsByTagName("title")[0].firstChild.nodeValue url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue) - type, ext, size = url_info(url) - download_urls([url], "%s - %s - %s" % (song_title, artist, album_name), ext, size, output_dir, merge = merge) + type, ext, size = url_info(url, faker = True) + + print_info(site_info, song_title, type, size) + if not info_only: + download_urls([url], "%s - %s - %s" % (song_title, artist, album_name), ext, size, output_dir, merge = merge, faker = True) def xiami_download_showcollect(sid, output_dir = '.', merge = True, info_only = False): xml = get_html('http://www.xiami.com/song/playlist/id/%s/type/3' % sid) @@ -48,8 +51,12 @@ def xiami_download_showcollect(sid, output_dir = '.', merge = True, info_only = album_name = i.getElementsByTagName("album_name")[0].firstChild.nodeValue song_title = i.getElementsByTagName("title")[0].firstChild.nodeValue url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue) - type, ext, size = url_info(url) - download_urls([url], "%02d.%s - %s - %s" % (track_nr, song_title, artist, album_name), ext, size, output_dir, merge = merge) + type, ext, size = url_info(url, faker = True) + + print_info(site_info, song_title, type, size) + if not info_only: + download_urls([url], "%02d.%s - %s - %s" % (track_nr, song_title, artist, album_name), ext, size, output_dir, merge = merge, faker = True) + track_nr += 1 def xiami_download_album(sid, output_dir = '.', merge = True, info_only = False): @@ -61,25 +68,26 @@ def xiami_download_album(sid, output_dir = '.', merge = True, info_only = False) for i in tracks: song_title = i.getElementsByTagName("title")[0].firstChild.nodeValue url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue) - type, ext, size = url_info(url) - download_urls([url], "%s - %02d.%s" % (album_name, track_nr, song_title), ext, size, output_dir, merge = merge) + type, ext, size = url_info(url, faker = True) + + print_info(site_info, song_title, type, size) + if not info_only: + download_urls([url], "%s - %02d.%s" % (album_name, track_nr, song_title), ext, size, output_dir, merge = merge, faker = True) + track_nr += 1 def xiami_download(url, output_dir = '.', stream_type = None, merge = True, info_only = False): - if re.match(r'http://www.xiami.com/album/\d+', url): id = r1(r'http://www.xiami.com/album/(\d+)', url) - return xiami_download_album(id, output_dir, merge, info_only) - + xiami_download_album(id, output_dir, merge, info_only) + if re.match(r'http://www.xiami.com/song/showcollect/id/\d+', url): id = r1(r'http://www.xiami.com/song/showcollect/id/(\d+)', url) - return xiami_download_showcollect(id, output_dir, merge, info_only) - + xiami_download_showcollect(id, output_dir, merge, info_only) + if re.match('http://www.xiami.com/song/\d+', url): id = r1(r'http://www.xiami.com/song/(\d+)', url) - return xiami_download_song(id) - - return None + xiami_download_song(id, output_dir, merge, info_only) site_info = "Xiami.com" download = xiami_download