tagged
view release on metacpan or search on metacpan
Revision history for Perl module MP3::Tag, MP3::TAG::ID3v1, MP3::TAG::ID3v2
Release Name: 0.1-beta
======================
Changes:
* Added documentation to the modules
* Writing/removing of ID3v2.3 tags is supported now
* Adding, changing, removing frames of ID3v2.3 is supported
* Changed directory structure
* Added file for proper install of modules
Release Name: 0.2-alpha
=======================
Changes:
* ID3v2.3 compressed frames are supported now
* changed directory structure, support librarys for MP3::Tag are now in a
subdirectory
* tagged.pl calls xview to show pictures, which were found in ID3v2 tags
(sorry, not configurable at the moment, but easy to change in tagged.pl)
Release Name: 0.1-alpha
=======================
This is the first alpha version. It contains perl modules to
read ID3v1/ID3v2 tags, but they are still lacking a lot of
features.
* Reading / Writing ID3v1 works
* Reading of most frames of ID3v2.3 works
Included is a demo program tagged.pl, and a program to change ID3v1
tags and to set automatically the filename of a mp3 file: tagit.pl See
README.txt for details. More documentation is still lacking. Sorry.
MP3::Tag can be found at http://sourceforge.net/projects/tagged
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'MP3::Tag',
'VERSION_FROM' => 'Tag.pm', # finds $VERSION
'PMLIBDIRS' => ['TAG', 'MP3::TAG'],
'AUTHOR' => '"Thomas Geffert" <thg@users.sourceforge.net>',
'PREREQ_PM' => {Compress::Zlib=>0},
);
MP3::Tag
============================================================
This is a perl module to read/write ID3v1, ID3v1.1 and ID3v2.3
tags of mp3-files. (Other tags hopefully to follow).
To install the MP3::TAG module you simply do:
perl Makefile.pl
make
make test
make install (as root)
If you find some errors while doing this, please send me
an email describing the problems.
In the directory examples, you find 2 examples, how to use
the module. You can also read the documentation of this
module with
man MP3::Tag
man MP3::TAG::ID3v1
man MP3::TAG::ID3v2
More information about this project, new releases and so on, can
be found at:
http://sourceforge.net/projects/tagged
Success with this
TAG/ID3v1.pm view on Meta::CPAN
%ok_length = (song => 30, artist => 30, album => 30, comment => 28, track => 3, genre => 30, year=>4, genreID=>1);
=pod
=head1 NAME
MP3::TAG::ID3v1 - Perl extension for reading / writing ID3v1 tags of mp3-files
=head1 SYNOPSIS
MP3::TAG::ID3v2 is designed to be called from the MP3::Tag module.
It then returns a ID3v2-tag-object, which can be used in a users
program.
use MP3::TAG::ID3v1;
$id3v1 = MP3::TAG::ID3v1->new($mp3obj);
C<$mp3obj> is a object from MP3::Tag. See according documentation.
C<$tag> is undef when no tag is found in the C<$mp3obj>.
* Reading the tag
print " Song: " .$id3v1->song . "\n";
print " Artist: " .$id3v1->artist . "\n";
print " Album: " .$id3v1->album . "\n";
print "Comment: " .$id3v1->comment . "\n";
print " Year: " .$id3v1->year . "\n";
print " Genre: " .$id3v1->genre . "\n";
TAG/ID3v1.pm view on Meta::CPAN
'Porn Groove', 'Satire', 'Slow Jam', 'Club', 'Tango', 'Samba',
'Folklore', 'Ballad', 'Power Ballad', 'Rhythmic Soul',
'Freestyle', 'Duet', 'Punk Rock', 'Drum Solo', 'Acapella',
'Euro-House', 'Dance Hall', );
}
=pod
=head1 SEE ALSO
MP3::Tag, MP3::TAG::ID3v2
ID3v1 standard - http://www.id3.org
=cut
TAG/ID3v2.pm view on Meta::CPAN
use vars qw /%format %long_names/;
=pod
=head1 NAME
MP3::TAG::ID3v2 - Read / Write ID3v2.3 tags from MP3 audio files
=head1 SYNOPSIS
MP3::TAG::ID3v2 is designed to be called from the MP3::Tag module.
It then returns a ID3v2-tag-object, which can be used in a users
program.
$id3v2 = MP3::TAG::ID3v2->new($mp3obj);
C<$mp3obj> is a object from MP3::Tag. See according documentation.
C<$tag> is undef when no tag is found in the C<$mp3obj>.
* Reading a tag
@frameIDs = $id3v2->getFrameIDS;
foreach my $frame (@frameIDs) {
my ($info, $name) = $id3v2->getFrame($frame);
if (ref $info) {
print "$name ($frame):\n";
TAG/ID3v2.pm view on Meta::CPAN
Thomas Geffert, thg@users.sourceforge.net
=head1 DESCRIPTION
=over 4
=item new()
$tag = new($mp3obj);
C<new()> needs as parameter a mp3obj, as created by C<MP3::Tag> (see documentation
of MP3::Tag).
C<new> tries to find a ID3v2 tag in the mp3obj. If it does not find a tag it returns undef.
Otherwise it reads the tag header, as well an extended header, if available. It reads the
rest of the tag in a buffer, does unsynchronizing if neccessary, and returns a ID3v2-object.
At this moment only ID3v2.3 is supported. Any extended header with CRC data is ignored, so
not CRC check is done at the moment.
The ID3v2-object can then be used to extract information from the tag.
=cut
sub new {
TAG/ID3v2.pm view on Meta::CPAN
WPAY => "Payment",
WPUB => "Publishers official webpage",
WXXX => "User defined URL link frame",
);
}
=pod
=head1 SEE ALSO
MP3::Tag, MP3::TAG::ID3v1
ID3v2 standard - http://www.id3.org
=cut
1;
package MP3::Tag;
################
#
# provides a general interface for different modules, which can read tags
#
# at the moment MP3::Tag works with MP3::TAG::ID3v1 and MP3::TAG::ID3v2
use strict;
use MP3::TAG::ID3v1;
use MP3::TAG::ID3v2;
use vars qw/$VERSION/;
$VERSION="0.1";
=pod
=head1 NAME
Tag - Perl extension reading tags of mp3 files
=head1 SYNOPSIS
use Tag;
$mp3 = MP3::Tag->new($filename);
$mp3->getTags;
if (exists $mp3->{ID3v1}) {
$id3v1 = $mp3->{ID3v1};
print $id3v1->song;
...
}
if (exists $mp3->{ID3v2}) {
($name, $info) = $mp3->{ID3v2}->getFrame("TIT2");
examples/README.txt view on Meta::CPAN
Short documentation of tagged.pl, tagit.pl and extractID3v2.pl
=====================================================================
You will find three perl programs as examples in this release.
You can use them after installing the MP3::Tag module. Look
at the README.txt in the main directory to see, how to do this.
Then simply run tagged.pl or tagit.pl (see description below),
giving filename(s) on the command line.
To run it you need Perl installed, at least 5.x I think. I wrote
this on Redhat Linux with Perl 5.6.0, but I think, it should run
with other versions too.
I didn't test it with windows. If you try to run it with windows,
please send me a short message, either if you had success or not.
Thomas <thg@users.sourceforge.net>
tagged.pl
#########
tagged.pl demonstrates at the moment the function of MP3::Tag. It
reads the tags of files, which are given on the command line, and
prints them to the console.
Later tagged.pl should be a program to change tags interactivly, to
check them for consistency (is there different information in ID3v1
and ID3v2 tag and/or the filename?), and so on...
tagit.pl
########
examples/tagged.pl view on Meta::CPAN
#!/usr/bin/perl -w
use strict;
use MP3::Tag;
my ($mp3, $count, $v1, $v2)=(undef,0,0,0);
die "usage: tagged.pl filename(s)" if $#ARGV == -1;
my $t = time;
for my $filename (@ARGV) {
next until -f $filename;
print " -- $filename:\n";
$mp3 = MP3::Tag->new($filename);
$mp3->getTags;
$count++;
if (exists $mp3->{ID3v1}) {
$v1++;
print " ** found ID3v1 - TAG\n";
print " Song: " .$mp3->{ID3v1}->song . "\n";
print " Artist: " .$mp3->{ID3v1}->artist . "\n";
print " Album: " .$mp3->{ID3v1}->album . "\n";
print "Comment: " .$mp3->{ID3v1}->comment . "\n";
print " Year: " .$mp3->{ID3v1}->year . "\n";
examples/tagit.pl view on Meta::CPAN
#!/usr/bin/perl -w
use MP3::Tag;
# some settings for getting command-line options
use Getopt::Long;
Getopt::Long::Configure(qw/no_ignore_case_always ignore_case bundling/);
my %options = ( '--song=s' => "Name of the song",
'--album=s' => "Album",
'--artist=s' => "Artist",
'--comment=s' => "Comment",
'--track=i' => "Track",
'--genre=s' => "Genre",
examples/tagit.pl view on Meta::CPAN
'--nospaces' => "Replace Spaces through _ in filenames",
'--test' => "Do NOT change the files. Only print which changes would be made",
'--skipwithoutv1' => "Don't do anything if no ID3v1 tag exists",
);
# get the command line options
my %opt;
getoptions(\%opt, %options);
if (exists $opt{showgenres}) {
my $genres = MP3::Tag::genres();
print join (", ", @$genres) ."\n";
}
unless ($#ARGV >=0) {
print "error: Filename(s) missing\n" unless exists $opt{showgenres};
exit 0 if exists $opt{showgenres};
exit 1;
}
# is there only one or more files to work with?
examples/tagit.pl view on Meta::CPAN
delete $opt{setfilename};
delete $opt{getfilename};
}
$opt{format} = "%a - %s.mp3" unless exists $opt{format};
my ($stencil, $details) = formatstr ($opt{format}) if exists $opt{setfilename} || exists $opt{getfilename};
# loop for each file
chomp(@ARGV = <STDIN>) unless @ARGV;
for my $filename (@ARGV) {
# get the tags
$mp3 = MP3::Tag->new($filename);
unless (defined $mp3) {
print "Skipping $filename ...\n";
next;
}
$mp3->getTags;
unless (exists $mp3->{ID3v1}) {
print "No ID3v1-Tag found\n" if exists $opt{show} || exists $opt{v};
next if exists $opt{skipwithoutv1};
$mp3->newTag("ID3v1");
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..11\n"; }
END {print "not ok 1\n" unless $loaded;}
use MP3::Tag;
$loaded = 1;
print "ok 1\n";
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
#test 2,3 - getting the tags
$mp3 = MP3::Tag->new("test.mp3");
$mp3->getTags;
$v1 = $mp3->{ID3v1};
ok($v1," 2 Detecting ID3v1");
$v2 = $mp3->{ID3v2};
ok($v2," 3 Detecting ID3v2");
#test 4 - reading ID3v1
ok(($v1 && ($v1->song eq "Song") && ($v1->track == 10))," 4 Reading ID3v1");
ok($v2 && $v2->getFrame("COMM")->{short} eq "Test!"," 5 Reading ID3v2");
#test 6,7 - writing ID3v1
ok($v1 && $v1->song("New")," 6 Changing ID3v1");
ok($v1 && $v1->writeTag," 7 Writing ID3v1");
#test 8,9 - writing ID3v2
ok($v2 && $v2->add_frame("TLAN","ENG")," 8 Changing ID3v2");
ok($v2 && $v2->write_tag," 9 Writing ID3v2");
$mp3 = MP3::Tag->new("test.mp3");
$mp3->getTags;
$v1 = $mp3->{ID3v1};
$v2 = $mp3->{ID3v2};
#test 10 - reading ID3v1
ok($v1 && $v1->song eq "New","10 Checking new ID3v1");
#test 11 - reading ID3v2
ok($v2 && $v2->getFrame("TLAN") eq "ENG","11 Checking new ID3v2");
( run in 1.469 second using v1.01-cache-2.11-cpan-0d23b851a93 )