[netease] resolve an issue about the HTTP error 404.
When you try the following command line:
you-get http://music.163.com/?#/playlist?id=484882742&_hash=songlist-368727
will fail in the 18th track:
Saving 016_1. 岛歌.lrc ...Done.
you-get: [error] oops, something went wrong.
you-get: don't panic, c'est la vie. please try the following steps:
you-get: (1) Rule out any network problem.
you-get: (2) Make sure you-get is up-to-date.
you-get: (3) Check if the issue is already known, on
you-get: https://github.com/soimort/you-get/wiki/Known-Bugs
you-get: https://github.com/soimort/you-get/issues
you-get: (4) Run the command with '--debug' option,
you-get: and report this issue with the full output.
The issue is caused by trying to download a non-existent mp3 file. (http://p2.music.126.net/Pnv-BvdHfOVrfVef1OY_7Q==/3221569069389100.mp3)
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\you_get\common.py", line 1322, in script_m
ain
download_main(download, download_playlist, args, playlist, output_dir=output
_dir, merge=merge, info_only=info_only, json_output=json_output, caption=caption
)
File "C:\Python34\lib\site-packages\you_get\common.py", line 1138, in download
_main
download(url, **kwargs)
File "C:\Python34\lib\site-packages\you_get\common.py", line 1405, in any_down
load
m.download(url, **kwargs)
File "C:\Python34\lib\site-packages\you_get\extractors\netease.py", line 133,
in netease_download
netease_cloud_music_download(url, output_dir, merge, info_only, **kwargs)
File "C:\Python34\lib\site-packages\you_get\extractors\netease.py", line 61, i
n netease_cloud_music_download
netease_song_download(i, output_dir=new_dir, info_only=info_only, playlist_p
refix=playlist_prefix)
File "C:\Python34\lib\site-packages\you_get\extractors\netease.py", line 120,
in netease_song_download
output_dir=output_dir, info_only=info_only)
File "C:\Python34\lib\site-packages\you_get\extractors\netease.py", line 123,
in netease_download_common
songtype, ext, size = url_info(url_best)
File "C:\Python34\lib\site-packages\you_get\common.py", line 413, in url_info
response = request.urlopen(request.Request(url))
File "C:\Python34\lib\urllib\request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "C:\Python34\lib\urllib\request.py", line 461, in open
response = meth(req, response)
File "C:\Python34\lib\urllib\request.py", line 571, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python34\lib\urllib\request.py", line 499, in error
return self._call_chain(*args)
File "C:\Python34\lib\urllib\request.py", line 433, in _call_chain
result = func(*args)
File "C:\Python34\lib\urllib\request.py", line 579, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
I noticed that there may be three links to download for each song, So I made some small changes to the code, so when there is a link return an HTTP error then they can continue to try other links.
I hope you can adopt this change, or maybe you have a better idea to fix the problem, thank you.
Hello @ddcatgg, Thanks for the Pull Request. We :heart: our contributors! Please wait for one of our human maintainers to review your patches. This may take a few days to weeks. Also, please understand that although your Pull Request may or may not be eventually merged, we value all contributions equally.
祝您健康!
Nice try!
May I have the logs being printed by log.info and log.wtf ? As should 3rd party extractors could experience error when reading from our stdout.
Many thanks!
I see, but I got stuck (timeout) on the second mp3Url link:
$ you-get -di http://music.163.com/song\?id\=327000
[DEBUG] get_content: http://music.163.com/api/song/detail/?id=327000&ids=[327000]&csrf_token=
hMusic url: http://p2.music.126.net/Pnv-BvdHfOVrfVef1OY_7Q==/3221569069389100.mp3
Traceback (most recent call last):
File "/home/soimort/Projects/you-get/src/you_get/extractors/netease.py", line 137, in netease_song_download
_download()
File "/home/soimort/Projects/you-get/src/you_get/extractors/netease.py", line 112, in _download
output_dir=output_dir, info_only=info_only)
File "/home/soimort/Projects/you-get/src/you_get/extractors/netease.py", line 147, in netease_download_common
songtype, ext, size = url_info(url_best)
File "/home/soimort/Projects/you-get/src/you_get/common.py", line 414, in url_info
response = request.urlopen(request.Request(url))
File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.5/urllib/request.py", line 472, in open
response = meth(req, response)
File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.5/urllib/request.py", line 510, in error
return self._call_chain(*args)
File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
result = func(*args)
File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
mp3Url url: http://m2.music.126.net/ZOkftVM3cOdXtQXOWliIww==/3218270534505732.mp3
@cnbeining please test this and merge if it looks valid to you.
It is good for me :)
E:\_PythonProg\you-get>py -3 you-get -di http://music.163.com/song?id=327000
[DEBUG] get_content: http://music.163.com/api/song/detail/?id=327000&ids=[327000
]&csrf_token=
hMusic url: http://p2.music.126.net/Pnv-BvdHfOVrfVef1OY_7Q==/3221569069389100.mp
3
Traceback (most recent call last):
File "E:\_PythonProg\you-get/src\you_get\extractors\netease.py", line 137, in
netease_song_download
_download()
File "E:\_PythonProg\you-get/src\you_get\extractors\netease.py", line 112, in
_download
output_dir=output_dir, info_only=info_only)
File "E:\_PythonProg\you-get/src\you_get\extractors\netease.py", line 147, in
netease_download_common
songtype, ext, size = url_info(url_best)
File "E:\_PythonProg\you-get/src\you_get\common.py", line 414, in url_info
response = request.urlopen(request.Request(url))
File "C:\Python36-32\lib\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "C:\Python36-32\lib\urllib\request.py", line 532, in open
response = meth(req, response)
File "C:\Python36-32\lib\urllib\request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python36-32\lib\urllib\request.py", line 570, in error
return self._call_chain(*args)
File "C:\Python36-32\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Python36-32\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
mp3Url url: http://m2.music.126.net/ZOkftVM3cOdXtQXOWliIww==/3218270534505732.mp
3
Site: 163.com
Title: 7. 能不能勇敢说爱
Type: MP3 (audio/mpeg)
Size: 3.69 MiB (3872391 Bytes)
[DEBUG] get_content: http://music.163.com/api/song/lyric/?id=327000&lv=-1&csrf_t
oken=
E:\_PythonProg\you-get>