Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Using Perl to organize my MP3's

by spurperl (Priest)
on Jan 06, 2003 at 16:34 UTC ( [id://224660]=CUFP: print w/replies, xml ) Need Help??

Dear fellow monks,

Just wanted to share an experience of how Perl made life easier (again !).
I like to organize my MP3's by giving them file names of the form "Author - Song".mp3... for some reason I despise MP3's ID3 tags.
Since a newer version of Winamp came in, it made up ID3v2 for all songs, and in winamp's playlist screen I see "no artist - no title" for all, and that's annoying. Changing thousands of MP3's manually is not fun enough to even start doing it, so I was mad for some time.

Today I finally decided to get it over with !
My MP3's are on the Win2k workstation, no Perl there (it's on the AIXes/Linuxes)... No problem, download Cygwin's Perl 5.8 port. Works great... OK, going to search.cpan.org, MP3::Tag seems suitable... Installing... Hmm, it's pretty complicated... Tinkering with the examples for a few minutes... Viola !
Another 15 minutes, and I had the following script that removes all ID3 tags from a given list of MP3's,
use MP3::Tag; foreach $filename (@ARGV) { print "$filename\n"; $mp3 = MP3::Tag->new($filename); # read an existing tag $mp3->get_tags(); if (exists $mp3->{ID3v2}) { $id3v2 = $mp3->{ID3v2}; $id3v2->remove_tag(); } if (exists $mp3->{ID3v1}) { $id3v1 = $mp3->{ID3v1}; $id3v1->remove_tag(); } }
and in another 5 minutes I have a nice, correct, Winamp playlist.

Replies are listed 'Best First'.
Re: Using Perl to organize my MP3's
by Aristotle (Chancellor) on Jan 06, 2003 at 19:30 UTC
    Or a little more compactly,
    exists $mp3->{$_} and $mp3->{$_}->remove_tag() for qw(ID3v1 ID3v2);
    or even
    $mp3->{$_}->remove_tag() for grep exists $mp3->{$_}, qw(ID3v1 ID3v2);

    Makeshifts last the longest.

      Nice, thanks...

      The duplicated code seemed a bit smelly to me, and yours is a nice solution.
Re: Using Perl to organize my MP3's
by batkins (Chaplain) on Jan 07, 2003 at 00:04 UTC
Re: Using Perl to organize my MP3's
by shotgunefx (Parson) on Jan 07, 2003 at 09:57 UTC
    I did something similar but instead of removing tags, I generated them from the directory structure and filename. I used MP3::ID3v1Tag which worked well.

    -Lee

    "To be civilized is to deny one's nature."
Re: Using Perl to organize my MP3's
by Anonymous Monk on Jan 25, 2003 at 23:55 UTC
    Not to devalue any of your work, but I think I should point out that Winamp can easily be configured to ignore the tags, which is IMHO preferable to stripping them. In Winamp's Preferences -> Input -> MPEG Decoder -> Title tab, there's a plainly marked checkbox for using the tags. This is as of Winamp 2.80, 3.x may be slightly different.
Re: Using Perl to organize my MP3's
by tstock (Curate) on Jan 07, 2003 at 04:36 UTC
    In the future, when you rip your CD's for legal copies, just don't make ID3 tags ?

    Tiago

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://224660]
Approved by pfaut
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found