Using Mutagen to process all accepted file types

What do I need to do to process each file type accepted by mutagen, .ogg, .apev2, .wma, flac, mp4 and asf? (I excluded mp3 because it has the most documentation)

I would appreciate it if someone who knows how to do this can provide some pseudo code to explain the methods used. The main tags that I would like to extract are the name and executor of the files, if available.

Where to begin?

+4
source share
1 answer

Each tag type has different names for the fields, and they are not all displayed perfectly.

, Mutagen "" ID3v2 MP4/ITMF. , , :

>>> m = mutagen.File(path, easy=True)
>>> m['title']
[u'Sunshine Smile']
>>> m['artist']
[u'Adorable']
>>> m['album']
[u'Against Perfection']

. Vorbis, Metaflac, APEv2 WMT : : [ ]. Vorbis , WM , WMP .NET API, Metaflac APEv2 . , "Artist", ID3v1, "ARTIST", Vorbis, Metaflac.

ID3v2 : iTunes "TPE1" "" "TPE2" " ", Foobar2000 TPE2 "" TXXX: ALBUM ARTIST as " ".

, iTMF, Vorbiscomment, ID3v2 ( . Wikipedia) WMT, , , , , , , .

, - :

>>> m = mutagen.File(path)
>>> for tag in ('TPE1', 'TPE2', u'©ART', 'Author', 'Artist', 'ARTIST',
...             'TRACK ARTIST', 'TRACKARTIST', 'TrackArtist', 'Track Artist'):
...     try:
...         artist = unicode(m[tag][0])
...         break
...     except KeyError:
...         pass

.

, . , , / Hydrogen Audio , , , MusicBrainz. MusicBrainz Picard Mutagen, ( ) .

+8

All Articles