From: W. Trevor King Date: Sat, 17 Dec 2011 18:55:03 +0000 (-0500) Subject: Add Mutagen post. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e258104e4466a206cf4292a9291394f099eca959;p=blog.git Add Mutagen post. --- diff --git a/posts/Mutagen.mdwn b/posts/Mutagen.mdwn new file mode 100644 index 0000000..bcc540d --- /dev/null +++ b/posts/Mutagen.mdwn @@ -0,0 +1,36 @@ +I just switched to [Mutagen][] as the metadata handler for my +[[mkogg]] utility. I used to use [metaflac][] and [id3v2][], but ran +up against limitations discussed on the `mkogg` page. Here's a quick +note on using Mutagen to set some [ID3][] tags: + + >>> from mutagen.mp3 import MP3 + >>> import mutagen.id3 + >>> audio = MP3('some_file.mp3') + >>> audio['TIT2'] = TIT2(encoding=3, text=["Title"]) + >>> audio.save(v1=2) # also include ID3v1 tags, when possible + +ID3v2 encodings are hardcoded to the [following table][encodings]: + + + + + + + + + + + +
ValueEncoding
0ISO-8859-1 (ASCII)
1UCS-2 in ID3v2.2 and ID3v2.3, UTF-16 encoded Unicode with BOM.
2UTF-16BE encoded Unicode without BOM in ID3v2.4 only.
3UTF-8 encoded Unicode in ID3v2.4 only.
+ +In order to get ID3v1 tags, you'll need to use frames and encodings +that ID3v1 understands. For encodings, that means `0` (ISO-8859-1). + +[Mutagen]: http://code.google.com/p/mutagen/ +[metaflac]: http://flac.sourceforge.net/documentation_tools_metaflac.html +[id3v2]: http://id3v2.sourceforge.net/ +[ID3]: http://en.wikipedia.org/wiki/ID3 +[encodings]: http://en.wikipedia.org/wiki/ID3#ID3v2 + +[[!tag tags/python]] +[[!tag tags/tools]]