[Tutor] How to map different keys together ?
damontimm at gmail.com
Sat Apr 17 17:57:28 CEST 2010
Hello - I am writing a script that converts an entire music library
into a single desired output format. The source music library has a
variety of music filetypes (flac, mp3, m4a, ogg, etc) and I am
attempting to use mutagen (a music file tagging module,
http://code.google.com/p/mutagen/) in order to handle the tagging.
I am struggling, on a theoretical level, on how to map the various
filetype's tag/key naming conventions. I have already created my own
MusicFile objects to handle each filetype (with functions for
encoding/decoding) but I can't wrap my head around how to map the
Here is a relevant (I think) example from mutagen for three different
filetypes all with the same tags (but different keys identifying
['album', 'disctotal', 'artist', 'title', 'tracktotal', 'genre',
'composer', 'date', 'tracknumber', 'discnumber']
['TPOS', u'APIC:', 'TDRC', 'TIT2', 'TPE2', 'TPE1', 'TALB', 'TCON', 'TCOM']
['\xa9alb', 'tmpo', '\xa9ART', '\xa9cmt', '\xa9too', 'cpil',
'----:com.apple.iTunes:iTunSMPB', '\xa9wrt', '\xa9nam', 'pgap',
'\xa9gen', 'covr', 'disk', '----:com.apple.iTunes:Encoding Params',
And here is what I would need to do to find the song's TITLE text:
>>> mp3['TIT2'].text #notice this one takes another additional step, as well, by specifying text !
In the end, after "the mapping", I would like to be able to do
something along these approaches:
 >>> target_file.tags = src_file.tags
 >>> target_file.set_tags(src_file.get_tags())
However, none of the keys match, so I need to somehow map them to a
central common source first ... and I am not sure about how to
approach this. I know I could manually assign each key to a class
property (using the @property tag) ... but this seems tedious:
Any insight on where I can start with mapping all these together?
More information about the Tutor