jesseward / discogstagger

Console based audio-file metadata tagger that uses the Discogs.com API v2 (JSON based). Relies on the Mutagen and discogs-client libraries. Currently supports FLAC and MP3 file types.
MIT License
70 stars 13 forks source link

URL double encoded #2

Closed cmaussan closed 12 years ago

cmaussan commented 12 years ago

Hi Jesse,

I have an other issue with discostagger :/ When I try this command line :

python ~/code/ext/discogstagger/discogs_tagger.py -r 3406100 -s Nordic\ by\ Night

I get this result :

INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): api.discogs.com DEBUG:requests.packages.urllib3.connectionpool:"GET /release/3406100 HTTP/1.1" 200 2225 INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): api.discogs.com DEBUG:requests.packages.urllib3.connectionpool:"GET /artist/Lindstr%25C3%25B8m HTTP/1.1" 404 75 INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): api.discogs.com DEBUG:requests.packages.urllib3.connectionpool:"GET /artist/Lindstr%25C3%25B8m HTTP/1.1" 404 75 INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): api.discogs.com DEBUG:requests.packages.urllib3.connectionpool:"GET /artist/Lindstr%25C3%25B8m HTTP/1.1" 404 75 Traceback (most recent call last): File "/home/cmaussan/code/ext/discogstagger/discogs_tagger.py", line 484, in logging.info("Tagging album '%s - %s'" % (release.artist, release.title)) File "/home/cmaussan/code/ext/discogstagger/discogs_tagger.py", line 141, in artist return self.clean_name(artist.data['name']) File "/home/cmaussan/code/ext/discogstagger/discogs_client.py", line 90, in data raise HTTPError(status_code) discogs_client.HTTPError: HTTP status 404: Not Found.

I can see it's because of the double encoding in URL. The GET should be /artist/Lindstr%C3%B8m and it's actually /artist/Lindstr%25C3%25B8m. I tryed to comment the urllib.quote( of line 81 in discogs_client.py but nothing changed :( Maybe it's in requests.get ...

Do you have any idea ?

Thanks,

Camille.

jesseward commented 12 years ago

Thanks again for reporting this.

The following is likely a problem with the data returned from the API, I will have a look at this problem later

DEBUG:requests.packages.urllib3.connectionpool:"GET /artist/Lindstr%25C3%25B8m HTTP/1.1" 404 75

But I shouldn't be calling the Artist class in the first place. The artist name property is cached and returned on the call via the Release class, so the extra call to Artists.data (essentially GET /artist/blah) can be removed (and error averted). I have made a small change to the way that the artists.name is accessed. You should no longer see this error, your release id now passes (see version 0.6).

 ./discogs_tagger.py -r 3406100 -s Nordic\ By\ Night
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): api.discogs.com
DEBUG:requests.packages.urllib3.connectionpool:"GET /release/3406100 HTTP/1.1" 200 2225
INFO:root:Tagging album 'Lindstrøm - Nordic By Night - Tsugi Sampler 49'
INFO:root:Creating destination directory 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/01-Todd_Terje-Myggsommer.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/02-Bjork-Crystalline_(Omar_Souleyman_Version).mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/03-Lumeet-Llyonesse_Zero.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/04-Mungolian_Jet_Set-We_Are_The_Shining_(Dan_Lissvik_Remix).mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/05-Magnus_International-Gamlefar.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/06-Ultracity-Azura.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/07-Carmen-Life_Is_Sin_(Prins_Thomas_Remix).mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/08-When_Saints_Go_Machine-Jets.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/09-Sandra_Kolstad-Leone.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/10-Ceo-White_Magic.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/11-Young_Dreams-Flight_376.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/12-The_Field-Is_This_Power.mp3'
DEBUG:root:Tagging 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/13-Gus_Gus-Selfoss.mp3'
INFO:root:Deleting source directory 'Nordic By Night'
INFO:root:Generating .nfo file
DEBUG:root:Writing file 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/00-Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49.nfo' to disk
INFO:root:Generating .m3u file
DEBUG:root:Writing file 'Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49-(TSUGI_49)-2012-jW/00-Lindstrm-Nordic_By_Night_-_Tsugi_Sampler_49.m3u' to disk
INFO:root:Downloading and storing images
DEBUG:root:Downloading image 'http://api.discogs.com/image/R-3406100-1329153544.jpeg'
DEBUG:root:Downloading image 'http://api.discogs.com/image/R-3406100-1329153557.jpeg'
INFO:root:Tagging complete.
cmaussan commented 12 years ago

Hi Jesse,

Thanks again for your reactivity.

I let you close the issue if you think it should be.

Camille.

jesseward commented 12 years ago

Thanks Camille, if 0.6 fixes your issue I will close this issue and follow up on the URL encoding separate of this issue

cmaussan commented 12 years ago

Yes it works :) Thanks again.

jesseward commented 12 years ago

Hey Camille.

You may want to update your requests library to latest and greatest as well. There were a few url encoding problems in initial 10.x releases. i have confirmed 10.4 (current as of today) works well .

see here for some additional comments : https://github.com/discogs/discogs_client/pull/11

cmaussan commented 12 years ago

Hi Jesse,

Thanks for the notice. I'll do that ;)