mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
catch exception in url_info(), fix xiami download error #146
This commit is contained in:
parent
a26da57c52
commit
e10068f656
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user