Closed bateast closed 11 years ago
Heh, that's what I get for copying over old code.
Thanks for the report; this should be easy to fix.
I'm going to increase the scope of this to include all unicode issues. A quick check shows I'm not handling unicode filepaths either (though I haven't run into it in tests yet).
Give 6145d04776d070691bcce498abf219bd73791718 a try; it worked for unicode filepath/metadata for me.
I can confirm it now works.
Thanks :)
I got this from a user:
2013-02-23 13:00:33,240 - gmusicapi (47) [INFO]: D:\music\mp3\Elton (Alexander Duszat) - Mühsam ernährt sich das Eichhörnchen Zum Glück bin ich keins
2013-02-23 13:00:33,571 - gmusicapi.api (739) [ERROR]: problem gathering local info of 'D:\music\mp3\Elton (Alexander Duszat) - Mühsam ernährt sich das Eichhörnchen Zum Glück bin ich keins\Mühsam ernährt sich das Eichhörnchen Zum Glück bin ich keins CD1.m4b'
Traceback (most recent call last):
File "C:\Users\Documents\My Dropbox\workspace\Unofficial-Google-Music-API\gmusicapi\api.py", line 736, in upload
track = musicmanager.UploadMetadata.fill_track_info(path)
File "C:\Users\Documents\My Dropbox\workspace\Unofficial-Google-Music-API\gmusicapi\protocol\musicmanager.py", line 211, in fill_track_info
track.title = os.path.basename(filepath)
File "build\bdist.win32\egg\google\protobuf\internal\python_message.py", line 435, in setter
type_checker.CheckValue(new_value)
File "build\bdist.win32\egg\google\protobuf\internal\type_checkers.py", line 128, in CheckValue
(proposed_value))
ValueError: 'M\xfchsam ern\xe4hrt sich das Eichh\xf6rnchen Zum Gl\xfcck bin ich keins CD1.m4b' has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added.
Since input comes from the user, I suppose we do have to guess the encoding (or find a way for os.path
to do it for us).
I chose to leave decoding up to the user so that upload has consistent behavior. The error message has been improved.
Hi,
a very simple uploader seems to crash on utf-8 title
BTW, I'm on 60707783b145064211bd05a09ced77bba5851806
" Successfully logged in.
Going to upload ['03-Sirba d Aordeon.mp3']
03-Sirba d Aordeon.mp3 <class 'mutagen.mp3.EasyMP3'> info bitrate: 128000 03-Sirba d Aordeon.mp3 client_id: "mWN9FWtMMzgKZtSdnXlT9Q" last_modified_timestamp: 1195391150 title: "Sirba d\'Accord\303\251on" artist: "Bratsch" album: "Sans Domicile Fixe" track_number: 3 genre: "Jazz" duration_millis: 191159 play_count: 0 rating: NOT_RATED estimated_size: 3053568 client_date_added: 0 recent_timestamp: 0 original_bit_rate: 128 original_content_type: MP3
track_sample { track { client_id: "mWN9FWtMMzgKZtSdnXlT9Q" last_modified_timestamp: 1195391150 title: "Sirba d\'Accord\303\251on" artist: "Bratsch" album: "Sans Domicile Fixe" track_number: 3 genre: "Jazz" duration_millis: 191159 play_count: 0 rating: NOT_RATED estimated_size: 3053568 client_date_added: 0 recent_timestamp: 0 original_bit_rate: 128 original_content_type: MP3 } signed_challenge_info { challenge_info { client_track_id: "mWN9FWtMMzgKZtSdnXlT9Q" start_millis: 113913 duration_millis: 15000 challenge_user_id: "102414142420569852921" challenge_timestamp: 1359374859 expect_match: false } signature: "<25 bytes>" } sample: "<240326 bytes>" } uploader_id: "B8:27:EB:E6:7D"
Traceback (most recent call last): File "/home/bateast/gmusic_uploader.py", line 96, in
main()
File "/home/bateast/gmusic_uploader.py", line 77, in main
uploaded, matched, not_uploaded = api.upload(file_list)
File "", line 2, in upload
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/utils/utils.py", line 186, in wrapper
return function(_args, _kw)
File "", line 2, in upload
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/utils/utils.py", line 163, in wrapper
return function(_args, _kw)
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/api.py", line 826, in upload
track, path, server_id)
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/api.py", line 664, in _make_call
request = protocol.build_request(_args, _kwargs)
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/newprotocol/shared.py", line 64, in build_request
val = val(_args, _kwargs)
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/newprotocol/musicmanager.py", line 314, in dynamic_data
"content": str(inlined[key]),
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 14: ordinal not in range(128)
"