Add Mutagen post.
authorW. Trevor King <wking@drexel.edu>
Sat, 17 Dec 2011 18:55:03 +0000 (13:55 -0500)
committerW. Trevor King <wking@drexel.edu>
Sat, 17 Dec 2011 18:55:03 +0000 (13:55 -0500)
posts/Mutagen.mdwn [new file with mode: 0644]

diff --git a/posts/Mutagen.mdwn b/posts/Mutagen.mdwn
new file mode 100644 (file)
index 0000000..bcc540d
--- /dev/null
@@ -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]:
+
+<table>
+  <thead>
+    <tr><td>Value</td><td>Encoding</td></tr>
+  </thead>
+  <tbody>
+    <tr><td>0</td><td>ISO-8859-1 (ASCII)</td></tr>
+    <tr><td>1</td><td>UCS-2 in ID3v2.2 and ID3v2.3, UTF-16 encoded Unicode with BOM.</td></tr>
+    <tr><td>2</td><td>UTF-16BE encoded Unicode without BOM in ID3v2.4 only.</td></tr>
+    <tr><td>3</td><td>UTF-8 encoded Unicode in ID3v2.4 only.</td></tr>
+  </tbody>
+</table>
+
+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]]