| AudioFile-Info-MP3-ID3Lib documentation | Contained in the AudioFile-Info-MP3-ID3Lib distribution. |
AudioFile::Info::MP3::ID3Lib - Perl extension to get info from MP3 files.
This is a plugin for AudioFile::Info which uses MP3::ID3Lib to get data about MP files.
See AudioFile::Info for more details.
Creates a new object of class AudioFile::Info::MP3::ID3Lib. Usually called by AudioFile::Info::new.
Dave Cross, <dave@dave.org.uk>
Copyright 2003 by Dave Cross
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| AudioFile-Info-MP3-ID3Lib documentation | Contained in the AudioFile-Info-MP3-ID3Lib distribution. |
package AudioFile::Info::MP3::ID3Lib; use 5.006; use strict; use warnings; use Carp; use MP3::ID3Lib; our $VERSION = sprintf "%d", '$Revision: 25 $ ' =~ /(\d+)/; my %data = (artist => 'TPE1', title => 'TIT2', album => 'TALB', track => 'TRCK', year => 'TYER', genre => 'TCON'); sub new { my $class = shift; my $file = shift; my $obj = MP3::ID3Lib->new($file); bless { obj => $obj }, $class; } sub DESTROY {} sub AUTOLOAD { our $AUTOLOAD; my ($pkg, $sub) = $AUTOLOAD =~ /(.+)::(\w+)/; die "Invalid attribute $sub" unless exists $data{$sub}; if ($_[1]) { my $attr = $_[1]; my $found; for (@{$_[0]->{obj}->frames}) { if($_->code eq $data{$sub}) { $found = 1; $_->set($attr); last; } } $_[0]->{obj}->add_frame($data{$sub}, $attr) unless $found; $_[0]->{obj}->commit; } for (@{$_[0]->{obj}->frames}) { return $_->value if $_->code eq $data{$sub}; } } 1; __END__