TagPy is a set of Python bindings for Scott Wheeler’s TagLib. It builds upon Boost.Python, a wrapper generation library which is part of the Boost set of C++ libraries [3].
Just like TagLib, TagPy can:
All these features have their own specific interfaces, but TagLib’s generic tag reading and writing mechanism is also supported. It comes with a bunch of examples.
TagPy is maintained in its git repository
Hi, does tagpy support Win32? I haven’t been able to get the latest version to install properly on Windows XP.
I’m having a hard time using unicode file paths to instantiate FileRef.
I have a filename that contains a ‘cent’ symbol, “20 ¢”.
When I attempt to open this file, I get an error.
Traceback
I realize that the TabLib library is not accepting the Unicode value. Is this something that can be fixed?
An attempt to fix this problem, on my end, is to convert all unicode values to ascii. (simply wrapping the filename in str() ). However, this attempt fails, because ASCII has no character representing ‘cents’.
Traceback
I hope you have a suggestion for me!
Thank you
Well, UNIX filenames are plain ASCII bytes, by definition. Conventionally, Unicode is then encoded in UTF8 and stored in these byte strings.
Unfortunately, this is only a convention, and you can’t rely on it. Therefore, Taglib (and Python) would make a huge mistake by making that assumption for you. Instead, you have to UTF-8 en/decode the filename yourself. Or better yet, only touch a file name’s encoding when you’re rendering it to text in a user interface.
Andreas
Update: I was able to use the latin_1 encoding without brandishing an error when encoding.
However, it does not correctly encode it.. I still get this error when opening the encoded filename:
TagLib: Could not open file /Volumes/Media/Unorganized Music/Moved from C/Goldfinger/Hang-Ups/05 20? Goodbye.mp3
It seems that I am going to be having problems regardless of what encoding I use, unless I can get Unicode working.
Well it looks like I solved my own problem thanks to some IRC support.
The solution was to explicitly encode my filename path in UTF-8
This confuses me… if my string is already unicode, why does explicitly encoding it in utf-8 fix the problem?
Thanks :)
A UTF-8
strobject is not the same as aunicodeobject. Python 3 will make this distinction more clear, wherestris renamedbytes(or some such) andunicodebecomes simplystr.Andreas
Hi, thanks for providing this wrapper! Is it true that the only tags available are: title, artist, album, genre, year, and track, or am I missing something? For example, composer would be another very useful thing to have access to for me.
You can get all these tags, too. Only problem: You need to use the file-format-specific APIs in that case, because there’s no portable way.
Download links does not seem to work now, can you please fix them?
Points to PyPI now, this should (in theory) never break ever again. Sorry for the fuss.
Post new comment