tblancher / pymazon

Automatically exported from code.google.com/p/pymazon
Other
0 stars 0 forks source link

Some tracks do not properly download without a proper user-agent string #59

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Upload a song (or album) that Amazon already has on their servers.
2. Attempt to download that song (as part of a playlist) or album.

What is the expected output? What do you see instead?
The song should be downloaded, but instead produces an error.

What version of the product are you using? On what operating system?
Pymazon 0.9.1 / Python 2.7 / Ubuntu 12.04.1

Please provide any additional information below.
The Amazon servers reject requests whose user-agent string doesn't match that 
of the Amazon MP3 Downloader.

The current Amazon downloader's string is "Amazon MP3 Downloader (Win32 1.0.17 
en_US)".

Of that string, it appears that the Win32 and en_US strings can be changed to 
whatever you want, and the version number must be greater than 1.0.12 (and must 
have two minor version numbers)

In the current version this can be fixed by changing the following line s in 
core/downloader.py

def _connect(self, obj):
         request = urllib2.Request(obj.url)
         obj.status = (0, 'Connecting...')

to

def _connect(self, obj):
         request = urllib2.Request(obj.url)
         request.add_header('User-Agent','Amazon MP3 Downloader (Win32 1.0.17 en_US)')
         obj.status = (0, 'Connecting...')

Original issue reported on code.google.com by jsphs...@gmail.com on 11 Oct 2012 at 3:40

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This is corrected in my clone repo. See 
http://code.google.com/r/jsphslgr-pymazon

Original comment by jsphs...@gmail.com on 4 Nov 2012 at 3:14

GoogleCodeExporter commented 8 years ago
I ran into the same issue with newly purchased music from Amazon as well; 
server requests for all tracks were failing with 500 Internal Server Error.  
The proposed fix to _connect() makes things work correctly.

(Pymazon 0.9.1 / Python 2.7 / Windows 7)

Original comment by dvor...@gmail.com on 11 Nov 2012 at 10:03

GoogleCodeExporter commented 8 years ago
I doubt that error 500 is sent in response to a "wrong" user agent.

As far as I've heard from jsphslgr, these problems only occur in connection 
with Cloud Player downloads.

I've just purchased a song from and was able to "pymazon" it without any 
special user agent string.

Original comment by Michael.Strecke on 11 Nov 2012 at 7:36

GoogleCodeExporter commented 8 years ago
I agree that the choice of response code seemed like obfuscation (if it was an 
intentional choice at all, rather than an actual error triggered by, from 
Amazon's point of view, an unsupported use case).  But I can absolutely 
reproduce it.

I bought three albums 2 days ago, and attempted to download them using pymazon. 
 Every single track was failing to download.  Some digging discovered that 
_DownloadWorker._connect() was failing, because the call to 
self.opener.open(request) was throwing.  The log file showed output like this, 
many times over:

2012-11-11 15:31:36,944 - downloader - ERROR - Opening request at url: 
http://www.amazon.com/cirrus/getDownloadUrlRedirect/XXXXXXXXXXXXXX/XXXXXXXXXXXXX
X/00000000000000000/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/0000000000000/0/xXxXxXx
XxXxXxXxXxXxXxX==/ 
 HTTP Error 500: Internal Server Error 

I would have been stuck at that point, but I happened to come across this 
ticket and tried the User-Agent work-around.  The error went away.  I tried it 
a few more times, and the error comes back without the User-Agent setting, and 
goes away with it.

Now, I understand that you're seeing something different, so all this may sound 
like "Who are you going to believe, me or your lying eyes?".  Apparently 
Amazon's doing different things in different cases here, perhaps depending on 
which server(s) you talk to.  But trust me, the problem is quite real for 
*some* users and *some* newly purchased music.

Original comment by dvor...@gmail.com on 12 Nov 2012 at 12:28

GoogleCodeExporter commented 8 years ago
Oh!  It helps when I re-read people's comments.

You are right: I was trying to download my new music *from the Cloud Player*, 
because I was having some trouble getting the .amz file from the initial 
download link.  Now that the cookie is set correctly I can get the .amz for the 
initial download, and I don't get the same failure.  (I do see other known 
errors, haven't fixed things yet.)

So yes, this does affect Cloud Player only, for purchased music as well as 
uploaded.  Sorry for the confusion on that point.

Original comment by dvor...@gmail.com on 12 Nov 2012 at 12:51

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have yet to experience this error for tracks that I've purchased, but I 
wouldn't be surprised if it was happening on some servers while Amazon rolls 
out new software.

If you're still getting known errors you might try using either my or 
michaelstrecke's repo. Both have fixes for the recent known download errors.

Original comment by jsphs...@gmail.com on 12 Nov 2012 at 2:07