MP3-Player in Python?

Joe Francia usenet at soraia.com
Wed Nov 19 12:51:05 EST 2003


"Thorsten Pferdek�����������������������������������" wrote:

<snip>
> 
> Concerning the ID3 tags, I have found the id3-py package
> (id3-py.sourceforge.net). It worked, but I dislike the automatic saving of
> changes on deconstruction. It also causes problems with german umlauts...
> It also seems not to support ID3v2.
> 

I don't know about playing them in a platform-independent way, but for 
tags, MP3Info from http://www.omniscia.org/~vivake/python/ seems to work 
very well.  Supports ID3v1, ID3v2 and Unicode, and is OS-agnostic:

#----------------------------------------
import MP3Info
import os
from operator import mod

basedir = '/music/l/liszt'
for song in os.listdir(basedir):
     f = file(os.path.join(basedir, song), 'rb')
     m = MP3Info.MP3Info(f)
     f.close()
     dur = '%d:%02d' % (m.mpeg.length/60, mod(m.mpeg.length, 60))
     print '[%s] - %s (%s)' % (m.artist, m.title, dur)

#----------------------------------------

Output:
[Leslie Howard] - Totentanz - Phantasie für Pianoforte und Orchester 
S126i - Andante - Allegro - Allegro moderato - (3:43)
[Leslie Howard] - Totentanz - Phantasie für Pianoforte und Orchester 
S126i - Variation 1 - Allegro moderato - (1:40)
(etc...)

Also, you don't mention Ogg Vorbis, but you may want to do it later:
http://www.andrewchatham.com/pyogg/

Peace,
Joe




More information about the Python-list mailing list