sk1418 / zhuaxia

download mp3 files/albums from xiami.com and music.163.com
Other
410 stars 83 forks source link

HTTP Error 404 #26

Closed notthesame23 closed 8 years ago

notthesame23 commented 8 years ago

Hi,

recently zhuaxia stopped working for me with netease completely. I tried it with many different files and options. Below is just a simple example. I tested it on two different OSX Machines, and I'm always getting the same error. I also setup zhuaxia using a china proxy. Xiami is still working with a proxy set, so i suppose proxy setup is working and it must be something else.

netease fails: zx http://music.163.com/song?id=1060910

DEBUG: DEBUG: downloader: 228: [DL_URL] downloading song Artur Rubinstein_Op. 9 - No. 1 In b flat.mp3 timeout! DEBUG: downloader: 229: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/zhuaxia-3.0.2-py2.7.egg/zhuaxia/downloader.py", line 208, in download_url_urllib r = urllib2.urlopen(url, timeout=30) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 127, in urlopen return _opener.open(url, data, timeout) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 410, in open response = meth(req, response) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 523, in http_response 'http', request, response, code, msg, hdrs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 448, in error return self._call_chain(_args) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 382, in _call_chain result = func(_args) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 531, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) HTTPError: HTTP Error 404: Not Found

xiami still works (for same track) with the following command: zx http://www.xiami.com/song/1769381230?spm=a1z1s.6659513.0.0.q28SPh

A quick google showed this: http://stackoverflow.com/questions/12302304/urllib2-returns-404-for-a-website-which-displays-fine-in-browsers

Something about setting a different User-agent within urllib2. To me it looks like netease is detecting that it is not accessed by a browser. I tried to hack in something like this in downloader.py, with no success: opener.addheaders = [('User-agent', 'Mozilla/5.0')]

Maybe you have an idea what might cause these download errors ?

Thank you !

notthesame23 commented 8 years ago

I just figured that in netease.py line 20: url_mp3="http://m5.music.126.net/%s/%s.mp3"

this page gives indeed a 404, even in browsers.

So i changed it to url_mp3="http://m1.music.126.net/%s/%s.mp3"

Now I could successfully download the above test track. Looks like they switched again the server, this seems to have happened in the past already. https://github.com/soimort/you-get/issues/743

So this issue has nothing todo with Proxies, or User-agent...sorry for the confusion.

sk1418 commented 8 years ago

@notthesame23 thx for digging into this problem. I am in company now, here I cannot test zhuaxia, since we have company proxy to internet. I remembered that the m5 doesn't check if the request IP is China IP. If it is not available any longer, we have to choose another one, however, China IP could be checked and needed. I will test with this.

sk1418 commented 8 years ago

changed 163's mp3 dl link to m1.... From my testing, now the China Proxy is required to download 163's songs. Without the proxy the above song example cannot be downloaded.

pushed to master.

notthesame23 commented 8 years ago

You're welcome, I'm always glad when I can actually help a little bit. Thx also to you for your fast response and pushing this to master. And yes, I guess proxy is definitely needed for now.