diff --git a/src/you_get/common.py b/src/you_get/common.py index 1a846b86..e963cf90 100644 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -134,10 +134,13 @@ def url_info(url, faker = False): else: type = None if headers['content-disposition']: - filename = parse.unquote(r1(r'filename="?(.+)"?', headers['content-disposition'])) - if len(filename.split('.')) > 1: - ext = filename.split('.')[-1] - else: + try: + filename = parse.unquote(r1(r'filename="?(.+)"?', headers['content-disposition'])) + if len(filename.split('.')) > 1: + ext = filename.split('.')[-1] + else: + ext = None + except: ext = None else: ext = None diff --git a/src/you_get/downloader/xiami.py b/src/you_get/downloader/xiami.py index 05e67a3c..75c61b42 100644 --- a/src/you_get/downloader/xiami.py +++ b/src/you_get/downloader/xiami.py @@ -43,6 +43,8 @@ def xiami_download_song(sid, output_dir = '.', merge = True, info_only = False): url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue) lrc_url = i.getElementsByTagName("lyric")[0].firstChild.nodeValue type, ext, size = url_info(url, faker = True) + if not ext: + ext = 'mp3' print_info(site_info, song_title, type, size) if not info_only: @@ -66,6 +68,8 @@ def xiami_download_showcollect(cid, output_dir = '.', merge = True, info_only = url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue) lrc_url = i.getElementsByTagName("lyric")[0].firstChild.nodeValue type, ext, size = url_info(url, faker = True) + if not ext: + ext = 'mp3' print_info(site_info, song_title, type, size) if not info_only: @@ -88,7 +92,9 @@ def xiami_download_album(aid, output_dir = '.', merge = True, info_only = False) url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue) lrc_url = i.getElementsByTagName("lyric")[0].firstChild.nodeValue type, ext, size = url_info(url, faker = True) - + if not ext: + ext = 'mp3' + print_info(site_info, song_title, type, size) if not info_only: file_name = "%02d.%s" % (track_nr, song_title)