Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Identifying MP3 files with no MP3 tag

by shockme (Chaplain)
on Jan 02, 2002 at 00:52 UTC ( #135550=CUFP: print w/replies, xml ) Need Help??

I have all of my CD collection stored as MP3 files. As part of this system, I have several Perl scripts which rely upon the MP3 tag in order to perform certain processes. As I was testing these scripts, I discovered that (for whatever reason) many of the MP3 files did not contain MP3 tag information.

The following script creates a file of all MP3 files which don't have MP3 tag information. This file can then be passed to another script for further processing.

The script is quick and dirty, is of obvious limited usefulness and could probably be coded more cleanly. However, it works and it works well. I'm just posting it here (1) because once again, Perl has the solution to my problem, and (2) in the hopes that others may find it useful.

Comments and improvements are most welcome.

#!/usr/bin/perl use strict; # only these fields need to be changed @ARGV = qw(/music/mp3/); # where MP3 files are located my $outfile = "$ENV{HOME}/mp3/NoTag"; # where to write the output # nothing below here needs to be changed open (MP3, "> $outfile") || die "can't open MP3: $!"; use File::Find; use MPEG::MP3Info; &File::Find::find(\&check, @ARGV); exit; sub check { if ($File::Find::name !~ /\.mp3$/) { return; } my $tag = get_mp3tag($File::Find::name); if (!($tag)) { # if no id tag, print print MP3 "$File::Find::name\n"; } }

If things get any worse, I'll have to ask you to stop helping me.

Replies are listed 'Best First'.
Re: Identifying MP3 files with no MP3 tag
by edebill (Scribe) on Jan 02, 2002 at 07:32 UTC

    I've been using a handy little utility called "mp3cddb" and it's companion "mp3cddbtag" to look up mp3's in the cddb database and tag them appropriately. Works quite well. And it's a perl script. :-)

    It might just make the perfect post-processing step after running your script. You can find it at http://k2.jozsef.kando.hu/~drewie/mp3cddb/

Re: Identifying MP3 files with no MP3 tag
by Rich36 (Chaplain) on Jan 02, 2002 at 23:52 UTC
    Quick question - Where is this function? my $tag = get_mp3tag($File::Find::name);. Is get_mp3tag() from a module that's not listed or a function that is not listed or am I missing something?
    Rich36
      get_mp3tag is provided by MPEG::MP3Info.

      If things get any worse, I'll have to ask you to stop helping me.

Re: Identifying MP3 files with no MP3 tag
by Kickstart (Pilgrim) on Jan 10, 2002 at 01:09 UTC
    Why not just parse the info that the 'file' command gives you?

    An example:

    $ file Tracy\ Chapman\ -\ Fast\ Car\ Live\ Acoustic.mp3 Tracy Chapman - Fast Car Live Acoustic.mp3: MP3, 128 kBits, 44.1 kHz, +JStereo

    And yes, if you are with the RIAA, I DO own the CD. :)

    Kickstart

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://135550]
Approved by root
help
Chatterbox?
[ambrus]: Corion: I mentioned that the unix event loop of Prima always wakes up at least once every 0.2 seconds. Have you found out whether the win32 event loop of Prima does that too?
[Corion]: ambrus: Hmm - I would assume that the onDestroy message is sent from the destructor and doesn't go through the messageloop, but maybe it is sent when a window gets destroyed but all components are still alive...
[ambrus]: Corion: partly deep source dive, partly just conservative coding even if it adds an overhead.
[Corion]: ambrus: Hmm - no, I haven't looked at wakeup intervals ... I wonder why it should want to wakeup periodically because it gets a lot of messages from the Windows message loop (on Windows obviously)
[ambrus]: (Alternately a deep source dive and then rewrite that event loop to make it better, and then as a bonus you get an idle method.)
[ambrus]: The 0.2 seconds wakeup is likely a workaround for some bug, but I can't guess what bug that is.
[ambrus]: It's been there since Prima 1.00 iirc
[Corion]: Hmmm... Weird. Maybe it needs that for doing its timers or something. Still weird.
[Corion]: But I guess I'll find out soonish, as my application seems to use Prima for more than just displaying the OpenGL output soonish ;))

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2016-12-09 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.