tblancher / pymazon

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

Exception when title (hence filename) contains non-ascii character. #35

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
pymazon v.09 on Gentoo IA32

Downloading a track that will generate a non-ascii character in the
resulting filename generates an Exception when stat() is called on the
pathname to determine if the file already exists.  Presumably it would
also fail were the path/file creation be attempted.

I'm not sure what the right thing to do is -- there must be some
normal "default" way of translating unicode strings into usable ascii
filenames.

I'll take a stab at a patch later this week after I look into the
whole unicode->ascii thing.

Here's the exception I got when attempting to download a track with
the title "Aprés Moi":

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.6/site-packages/pymazon/core/downloader.py", line 54, in run
    self.do_work()
  File "/usr/lib/python2.6/site-packages/pymazon/core/downloader.py", line 68, in do_work
    obj.save(data)
  File "/usr/lib/python2.6/site-packages/pymazon/core/item_model.py", line 127, in save
    super(Track, self).save(save_path, data)
  File "/usr/lib/python2.6/site-packages/pymazon/core/item_model.py", line 77, in save
    fname = self._safe_save_name(fname)
  File "/usr/lib/python2.6/site-packages/pymazon/core/item_model.py", line 70, in _safe_save_name
    if not os.path.isfile(nfname):
  File "/usr/lib/python2.6/genericpath.py", line 29, in isfile
    st = os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 
51: ordinal not in range(128)

Original issue reported on code.google.com by Grant.B....@gmail.com on 7 Feb 2011 at 9:24

GoogleCodeExporter commented 8 years ago
Odd -- according to the Python unicode howto, the filesystem library
calls should automagically convert unicode filenames into legal values
for the underlying filesystem.  When I added some code to try to
figure out exactly what was going on, I found that I can no longer
download using the .amz file containing the problematic track.

Do .amz files expire?

Original comment by Grant.B....@gmail.com on 8 Feb 2011 at 3:33

GoogleCodeExporter commented 8 years ago
yes .amz files expire. You can typically download the tracks a couple times 
back to back in a short time window, then the url's expire.

Original comment by SCColbert@gmail.com on 8 Feb 2011 at 3:44

GoogleCodeExporter commented 8 years ago
While that's an understandable and reasonable thing for Amazon to do,
it would seem to make development work on a downloader difficult.

How does one test changes?

Original comment by Grant.B....@gmail.com on 8 Feb 2011 at 3:53

GoogleCodeExporter commented 8 years ago
Well, given that amazon DES encrypts the .amz file, I don't think they are very 
supportive of community efforts to build a downloader :) 

That said, I uploaded some mp3's to my own server and created a .amz file with 
the urls pointing there, then re-encrypted the file. I use that "fake" amz for 
testing.

Original comment by SCColbert@gmail.com on 8 Feb 2011 at 3:58

GoogleCodeExporter commented 8 years ago
Setting up a test server was the only thing I could think of.  I
probably won't have time to set up something like that for a while.

Original comment by Grant.B....@gmail.com on 8 Feb 2011 at 4:02

GoogleCodeExporter commented 8 years ago
Setting up a test server was the only thing I could think of.  I
probably won't have time to set up something like that for a while.

Original comment by Grant.B....@gmail.com on 8 Feb 2011 at 4:06