| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # | 
| 2 |  |  |  |  |  |  | # $Id: $ | 
| 3 |  |  |  |  |  |  | # | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =head1 NAME | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | AudioFile::Info::MP4::Info - Perl extension to get info from MP4 files. | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | Extracts data from an MP4 file using the CPAN module | 
| 12 |  |  |  |  |  |  | MP4::Info. | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | See L for more details. | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | =cut | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | package AudioFile::Info::MP4::Info; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 1 |  |  | 1 |  | 2367 | use 5.006; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 112 |  | 
| 21 | 1 |  |  | 1 |  | 6 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 41 |  | 
| 22 | 1 |  |  | 1 |  | 17 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 37 |  | 
| 23 | 1 |  |  | 1 |  | 5 | use Carp; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 99 |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 1 |  |  | 1 |  | 1050 | use MP4::Info; | 
|  | 1 |  |  |  |  | 414843 |  | 
|  | 1 |  |  |  |  | 342 |  | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | our $VERSION = "0.6"; | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | my %data = (artist => ['ART',      'ARTIST'], | 
| 30 |  |  |  |  |  |  | title  => ['NAM',      'TITLE'], | 
| 31 |  |  |  |  |  |  | album  => ['ALB',      'ALBUM'], | 
| 32 |  |  |  |  |  |  | track  => ['TRACKNUM', 'TRKN'], | 
| 33 |  |  |  |  |  |  | year   => ['DATE',     'YEAR'], | 
| 34 |  |  |  |  |  |  | genre  => ['GNRE',     'GENRE']); | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | sub new { | 
| 37 | 0 |  |  | 0 | 1 |  | my $class = shift; | 
| 38 | 0 |  |  |  |  |  | my $file  = shift; | 
| 39 | 0 |  | 0 |  |  |  | my $obj   = get_mp4tag($file) || die "Couldn't get MP4 info for $file"; | 
| 40 | 0 |  |  |  |  |  | bless { obj => $obj }, $class; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 0 |  |  | 0 |  |  | sub DESTROY {} | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | sub AUTOLOAD { | 
| 46 | 0 |  |  | 0 |  |  | our $AUTOLOAD; | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 0 |  |  |  |  |  | my ($pkg, $sub) = $AUTOLOAD =~ /(.*)::(\w+)/; | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 0 | 0 |  |  |  |  | die "Invalid attribute $sub" unless $data{$sub}; | 
| 51 | 0 |  |  |  |  |  | foreach my $try (@{$data{$sub}}) { | 
|  | 0 |  |  |  |  |  |  | 
| 52 | 0 | 0 |  |  |  |  | return $_[0]->{obj}->{$try} if defined $_[0]->{obj}->{$try}; | 
| 53 |  |  |  |  |  |  | } | 
| 54 | 0 |  |  |  |  |  | return undef; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | 1; | 
| 59 |  |  |  |  |  |  | __END__ |