fix m5.music.126.net return 404

This commit is contained in:
xyuanmu 2016-02-04 11:48:16 +08:00
parent af8d827d57
commit 9c0abc6c64
2 changed files with 6 additions and 4 deletions

View File

@ -348,6 +348,7 @@ def url_info(url, faker = False, headers = {}):
headers = response.headers
type = headers['content-type']
if type == 'image/jpg; charset=UTF-8' or type == 'image/jpg' : type = 'audio/mpeg' #fix for netease
mapping = {
'video/3gpp': '3gp',
'video/f4v': 'flv',

View File

@ -94,13 +94,14 @@ def netease_video_download(vinfo, output_dir='.', info_only=False):
def netease_song_download(song, output_dir='.', info_only=False):
title = "%s. %s" % (song['position'], song['name'])
songNet = 'p' + song['mp3Url'].split('/')[2][1:]
if 'hMusic' in song and song['hMusic'] != None:
url_best = make_url(song['hMusic']['dfsId'])
url_best = make_url(songNet, song['hMusic']['dfsId'])
elif 'mp3Url' in song:
url_best = song['mp3Url']
elif 'bMusic' in song:
url_best = make_url(song['bMusic']['dfsId'])
url_best = make_url(songNet, song['bMusic']['dfsId'])
netease_download_common(title, url_best,
output_dir=output_dir, info_only=info_only)
@ -165,9 +166,9 @@ def encrypted_id(dfsId):
return result
def make_url(dfsId):
def make_url(songNet, dfsId):
encId = encrypted_id(dfsId)
mp3_url = "http://m5.music.126.net/%s/%s.mp3" % (encId, dfsId)
mp3_url = "http://%s/%s/%s.mp3" % (songNet, encId, dfsId)
return mp3_url