antlarr / bard

Bard Music Manager - A database to manage your music, find duplicates and fix tags
GNU General Public License v3.0
63 stars 5 forks source link

codec can't encode character #5

Open janverm opened 6 years ago

janverm commented 6 years ago

When importing my music, the addSong function triggered an exception when importing some Ogg Vorbis files with unicode characters:

  File "/usr/lib/python3.6/site-packages/bard-0.1.0-py3.6-linux-x86_64.egg/bard/musicdatabase.py", line 199, in addSong
    print(values[0][3:])
UnicodeEncodeError: 'ascii' codec can't encode character '\xa5' in position 35: ordinal not in range(128)

Please update the code to either ignore the non-ascii unicode chars or implement all strings in database as unicode strings. ( yourstring.encode('ascii', 'ignore').decode('ascii') )

See also: https://docs.python.org/3.6/howto/unicode.html#python-s-unicode-support

antlarr commented 6 years ago

If I understand you correctly that happens with filenames having unicode characters (not with unicode characters in the metadata of those files), is that right?

If that's the case maybe the problem is within the encoding of the filenames? I have many files with unicode characters and never had any problem with them. Maybe you moved those files over samba/windows systems at some point and the encoding was broken? I found some of those cases and fixed them by using convmv -f iso-8859-1 -t utf-8 *.ogg (maybe your from encoding should be different, you can also try cp850 for example instead of iso-8859-1). Once you're happy with the result, you can run convmv with --notest to actually perform the renaming of the files (by default it does a dry run).

If that doesn't help, can you provide me with the output of ls -1 *.ogg as well as the output of ls -1 *.ogg | hexdump -C ? Thanks