line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::MP3::Tag; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
4
|
|
|
|
|
|
|
# $Id: Tag.pm,v 1.7 2006/04/24 03:30:05 travail Exp $ |
5
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
604567
|
use 5.008002; |
|
6
|
|
|
|
|
29
|
|
|
6
|
|
|
|
|
420
|
|
8
|
6
|
|
|
6
|
|
41
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
284
|
|
9
|
6
|
|
|
6
|
|
40
|
use warnings; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
269
|
|
10
|
6
|
|
|
6
|
|
34
|
use vars qw ( $VERSION $AUTOLOAD ); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
386
|
|
11
|
6
|
|
|
6
|
|
35
|
use base qw( Template::Plugin ); |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
6257
|
|
12
|
6
|
|
|
6
|
|
7567
|
use MP3::Tag (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Template::Plugin; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $ETYPE = 'plugin.mp3_tag'; |
16
|
|
|
|
|
|
|
$VERSION = '0.01'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
|
|
|
|
|
|
my ( $class, $context, $file ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
-e $file || $context->throw( $ETYPE, "File '$file' does not exist" ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $mp3_tag = MP3::Tag->new( $file ) |
24
|
|
|
|
|
|
|
|| $context->throw( $ETYPE, "Can't create MP3::Tag object for mp3 file '$file'" ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
bless { |
27
|
|
|
|
|
|
|
_CONTEXT => $context, |
28
|
|
|
|
|
|
|
_FILE => $file, |
29
|
|
|
|
|
|
|
_MP3_TAG => $mp3_tag |
30
|
|
|
|
|
|
|
}, $class; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub AUTOLOAD { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $method = $AUTOLOAD; |
37
|
|
|
|
|
|
|
$method =~ s/.*:://; |
38
|
|
|
|
|
|
|
return if ( $method eq 'DESTROY' ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return $self->{_MP3_TAG}->$method( @_ ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub album { |
44
|
|
|
|
|
|
|
my ( $self ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return $self->autoinfo->{album}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub artist { |
50
|
|
|
|
|
|
|
my ( $self ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return $self->autoinfo->{artist}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub song { |
56
|
|
|
|
|
|
|
my ( $self ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return $self->autoinfo->{song}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub track { |
62
|
|
|
|
|
|
|
my ( $self ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $self->autoinfo->{track}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub title { |
68
|
|
|
|
|
|
|
my ( $self ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return $self->autoinfo->{title}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub genre { |
74
|
|
|
|
|
|
|
my ( $self ) = @_; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
return $self->autoinfo->{genre}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub year { |
80
|
|
|
|
|
|
|
my ( $self ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return $self->autoinfo->{year}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |