line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
1
|
|
169076
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
8
|
1
|
|
|
1
|
|
5
|
use vars qw( $VERSION $AUTOLOAD ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
9
|
1
|
|
|
1
|
|
18
|
use base qw( Template::Plugin ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
942
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $ETYPE = "plugin.mp3"; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5459
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
14
|
1
|
|
|
1
|
|
4590
|
use MP3::Info (); |
|
1
|
|
|
|
|
65696
|
|
|
1
|
|
|
|
|
30
|
|
15
|
1
|
|
|
1
|
|
12
|
use Template::Plugin; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
431
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
sub new { |
29
|
1
|
50
|
|
1
|
1
|
117
|
my $config = ref($_[-1]) eq 'HASH' ? pop @_ : { }; |
30
|
1
|
|
|
|
|
3
|
my ($class, $context, $file) = @_; |
31
|
1
|
|
|
|
|
2
|
my ($dir, $mp3); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Allow filename to be positional or named |
34
|
1
|
50
|
33
|
|
|
8
|
$file = $config->{'name'} |
35
|
|
|
|
|
|
|
if (! defined $file && defined $config->{'name'}); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Allowances for Template::Plugin::File instances |
38
|
1
|
50
|
|
|
|
9
|
$file = $file->name |
39
|
|
|
|
|
|
|
if (UNIVERSAL::can($file, "name")); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Allow filename to be relative to a root directory |
42
|
1
|
50
|
|
|
|
5
|
$file = File::Spec->catfile($config->{'dir'}, $file) |
43
|
|
|
|
|
|
|
if defined $config->{'dir'}; |
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
21
|
-e $file or $context->throw($ETYPE, "File '$file' does not exist"); |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
33
|
|
|
7
|
$mp3 = MP3::Info->new($file) |
48
|
|
|
|
|
|
|
|| $context->throw($ETYPE, |
49
|
|
|
|
|
|
|
"Can't create MP3::Info object for mp3 file '$file'"); |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
2467
|
if (defined $config->{'utf8'}) { |
52
|
0
|
|
|
|
|
0
|
MP3::Info::use_mp3_utf8($config->{'utf8'}); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
bless { |
56
|
1
|
|
|
|
|
11
|
_CONTEXT => $context, |
57
|
|
|
|
|
|
|
_MP3 => $mp3, |
58
|
|
|
|
|
|
|
} => $class; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub AUTOLOAD { |
62
|
5
|
|
|
5
|
|
1034
|
my $self = shift; |
63
|
5
|
|
|
|
|
26
|
(my $a = $AUTOLOAD) =~ s/.*:://; |
64
|
|
|
|
|
|
|
|
65
|
5
|
50
|
|
|
|
22
|
if (exists $self->{ _MP3 }->{uc $a}) { |
66
|
5
|
|
|
|
|
46
|
return $self->{ _MP3 }->$a(@_) ; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
0
|
|
|
|
|
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
0
|
|
sub mp3_genres { [ @MP3::Info::mp3_genres ] } |
74
|
0
|
|
|
0
|
0
|
|
sub winamp_genres { [ @MP3::Info::winamp_genres ] } |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub genres { |
77
|
0
|
|
|
0
|
0
|
|
my @mp3_genres = mp3_genres; |
78
|
0
|
|
|
|
|
|
my @winamp_genres = winamp_genres; |
79
|
0
|
|
|
|
|
|
return [ @mp3_genres, @winamp_genres ] |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |