| 1 | package Template::Plugin::MP3; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 4 | # $Id: MP3.pm,v 1.1.1.1 2003/06/24 13:42:29 dlc Exp $ | ||||||||||||||||||||||||||||
| 5 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use vars qw( $VERSION $AUTOLOAD ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use base qw( Template::Plugin ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | my $ETYPE = "plugin.mp3"; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use MP3::Info (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Template::Plugin; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | $VERSION = 1.02; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 20 | # new($context, $name, \%config) | ||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||
| 22 | # Creates a new MP3 instance. Requires the name of an MP3 file, | ||||||||||||||||||||||||||||
| 23 | # either as the first positional argument or as the 'name' element of | ||||||||||||||||||||||||||||
| 24 | # the configuration hash. The user can also specify a base directory | ||||||||||||||||||||||||||||
| 25 | # (using 'dir'), which will be used as a base for the aforementioned | ||||||||||||||||||||||||||||
| 26 | # name. | ||||||||||||||||||||||||||||
| 27 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 28 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | my $config = ref($_[-1]) eq 'HASH' ? pop @_ : { }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 1 | my ($class, $context, $file) = @_; | |||||||||||||||||||||||||||
| 31 | 1 | my ($dir, $mp3); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # Allow filename to be positional or named | ||||||||||||||||||||||||||||
| 34 | $file = $config->{'name'} | ||||||||||||||||||||||||||||
| 35 | 1 | ▶ | if (! defined $file && defined $config->{'name'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $file and defined $config->{"name"}
MC/DC0%0/2
not defined $file and defined $config->{"name"}
not defined $file
defined $config->{"name"}
Truth table33%1/3
not(A) and B
A= not defined $fileB= defined $config->{"name"}
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # Allowances for Template::Plugin::File instances | ||||||||||||||||||||||||||||
| 38 | 1 | ▶ | $file = $file->name | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | if (UNIVERSAL::can($file, "name")); | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # Allow filename to be relative to a root directory | ||||||||||||||||||||||||||||
| 42 | $file = File::Spec->catfile($config->{'dir'}, $file) | ||||||||||||||||||||||||||||
| 43 | 1 | ▶ | if defined $config->{'dir'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 1 | ▶ | -e $file or $context->throw($ETYPE, "File '$file' does not exist"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | $mp3 = MP3::Info->new($file) | ||||||||||||||||||||||||||
|
Condition33%1/3
'MP3::Info'->new($file) || $context->throw($ETYPE, "Can't create MP3::Info object for mp3 file '${file}'")
MC/DC0%0/2
'MP3::Info'->new($file) || $context->throw($ETYPE, "Can't create MP3::Info object for mp3 file '${file}'")
'MP3::Info'->new($file)
$context->throw($ETYPE, "Can't create MP3::Info object for mp3 file '${file}'")
Truth table33%1/3
A || B
A= 'MP3::Info'->new($file)B= $context->throw($ETYPE, "Can't create MP3::Info object for mp3 file '${file}'")
| |||||||||||||||||||||||||||||
| 48 | || $context->throw($ETYPE, | ||||||||||||||||||||||||||||
| 49 | "Can't create MP3::Info object for mp3 file '$file'"); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | if (defined $config->{'utf8'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | MP3::Info::use_mp3_utf8($config->{'utf8'}); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | bless { | ||||||||||||||||||||||||||||
| 56 | 1 | _CONTEXT => $context, | |||||||||||||||||||||||||||
| 57 | _MP3 => $mp3, | ||||||||||||||||||||||||||||
| 58 | } => $class; | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 5 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||
| 62 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | 5 | (my $a = $AUTOLOAD) =~ s/.*:://; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 5 | ▶ | if (exists $self->{ _MP3 }->{uc $a}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 5 | return $self->{ _MP3 }->$a(@_) ; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | else { | ||||||||||||||||||||||||||||
| 69 | 0 | return; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub mp3_genres { [ @MP3::Info::mp3_genres ] } | ||||||||||||||||||||||||||
|
Subroutine
mp3_genres: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub winamp_genres { [ @MP3::Info::winamp_genres ] } | ||||||||||||||||||||||||||
|
Subroutine
winamp_genres: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub genres { | ||||||||||||||||||||||||||
|
Subroutine
genres: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 0 | my @mp3_genres = mp3_genres; | |||||||||||||||||||||||||||
| 78 | 0 | my @winamp_genres = winamp_genres; | |||||||||||||||||||||||||||
| 79 | 0 | return [ @mp3_genres, @winamp_genres ] | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||