On May 29, 5:26 am, Kalibr <[EMAIL PROTECTED]> wrote: > On May 29, 7:55 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > > > > > > > You don't say, but I assume you're on Windows since you mention > > GetFileVersionInfo (which doesn't have anything to do with media > > files, by the way) and WMA. There may be packages out there > > to do all this already but if not you'll need to pull in a few disparate > > modules and mix'n'match. > > > While ID3 readers (which determine the metadata for MP3) are reasonably > > common few of them come ready-compiled for Windows. I've used Ned > > Batchelder's id3reader [1] successfully for simple tasks so you might try > > that. On the WMA side, you can automate Windows Media Player to get > > metadata. (And it might work for .mp3; I've not tried). > > > <code> > > import win32com.client > > > player = win32com.client.gencache.EnsureDispatch ("WMPlayer.OCX") > > wmedia = player.mediaCollection.add (r"c:\temp\bells.mp3") > > try: > > artist = wmedia.getItemInfo ("Artist") > > finally: > > player.mediaCollection.remove (wmedia, False) > > > print "bells.mp3 has artist", artist > > > </code> > > > You're going to have to dig around for docs on this one. And it's not > > pretty. Try starting from: > > >http://msdn.microsoft.com/en-us/library/bb249009(VS.85).aspx > > > TJG > > > [1]http://nedbatchelder.com/code/modules/id3reader.html > > Hmm, thanks for the info. Yes, I am using Winders (Vista to be exact) > and I just assumed that there must be a way to programmatically get > the stuff you get from choosing properties in the right click menu. > But I guess there isn't (hard to believe, because I can't see MS hard- > coding each and every file format's metadata into it's OS). I might > have to learn more about the command prompt ( I hear there is a module > for fiddling with it) and work from there. > > Cheers for the links though, I will be checking them out :)
You might also check out the ID3 library: http://id3-py.sourceforge.net/ It doesn't look like it's been updated for a few years. I tested it on XP and it seems to work though. I also found this snippet, but it's pretty rudimentary: http://snipplr.com/view/1624/python--get-id3-from-mp3-file/ Finally, check out the ID3 Handling section on this site: http://wiki.python.org/moin/UsefulModules ------- Mike Blog: http://blog.pythonlibrary.org/ -- http://mail.python.org/mailman/listinfo/python-list