MP3::ID3v1Tag - Edit ID3v1 Tags from an Audio MPEG Layer 3.
use MP3::ID3v1Tag; $mp3_file = new MP3::ID3v1Tag("filename.mp3"); $mp3_file->print_tag(); if($mp3_file->got_tag()) { $mp3_file->set_title($title); $save_status = $mp3_file->save(); }
The ID3v1Tag routines are useful for setting and reading ID3 MP3 Audio Tags. Just create an MP3::ID3v1Tag Object with the path to the file of interest, and query any of the methods below.
To get a print out of all the header information (Default FileHandler), simply state the following
$mp3_file->print_tag();
With an optional number of columns argument (default is 3) this will return a list of genre numbers with their appropriate genre.
$mp3_file->print_genre_chart($COLUMNS);
There is a handy method named got_tag() that can be easily used to determine if a particular MP3 file contains an ID3 Tag.
if $mp3_file->got_tag() { $mp3_file->print_tag(); }
There exist several methods that will return you the individual components of the ID3 Tag.
$title = $mp3_file->get_title(); $artist = $mp3_file->get_artist(); $album = $mp3_file->get_album(); $year = $mp3_file->get_year(); $genre = $mp3_file->get_genre(); $genre_num = $mp3_file->get_genre_num(); $comment = $mp3_file->get_comment();
Similar methods exist to allow you to change the components of the Tag, but none of the changes will actually be changed in the file until you call the save() routine.
$mp3_file->set_title("New Title"); $mp3_file->set_artist("New Artist"); $mp3_file->set_album("New Album"); $mp3_file->set_year(1999); $mp3_file->set_genre("Blues"); # Or use the genre numbers -> $mp3_file->set_genre_num(0);
To remove an tag in its entirely just calling the remove_tag() method should work for you.
$mp3_file->remove_tag() if $mp3_file->got_tag(); You could access all the components directly for a read only loop such as the following
foreach (sort $mp3_file->tag) { print "$_: " . $mp3_file->tag($_) . "\n"; }
Sander van Zoest <svanzoest@cpan.org>
Matt Plummer <matt@mp3.com>, Mike Oliphant <oliphant@gtk.org>, Matt DiMeo <mattd@mp3.com>, Olaf Maetzner, Jason Bodnar and Peter Johansson
Copyright 2000, Alexander van Zoest. All rights reserved. Copyright 1999-2000, Alexander van Zoest, MP3.com, Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
For general overview of MPEG 1.0, Layer 3 (MP3) Audio visit <http://help.mp3.com/help/gettingstarted/guide.html> or get the book, "MP3: The Definitive Guide" by O'Reilly and Associates <http://www.oreilly.com/catalog/mp3/>.
For technical details about MP3 Audio read the ISO/IEC 11172 and ISO/IEC 13818 specifications, obtained via <http://www.ANSI.org/> in the US or <http://www.ISO.ch/> elsewhere in the world. For more information also check out <http://www.mp3-tech.org/> compiled by Gabriel Bouvigne.
For more specific references to the MP3 Audio ID3 Tags visit <http://www.id3.org/>
For information about ID3v2 and a perl implementation see MPEG::ID3v2Tag written by Matt DiMeo <mattd@mp3.com>.
To install MP3::ID3v1Tag, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MP3::ID3v1Tag
CPAN shell
perl -MCPAN -e shell install MP3::ID3v1Tag
For more information on module installation, please visit the detailed CPAN module installation guide.