| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Template::Plugin::AudioFile::Info; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
463910
|
use 5.006; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
36
|
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
38
|
|
|
5
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
55
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
379
|
use AudioFile::Info; |
|
|
2
|
|
|
|
|
33834
|
|
|
|
2
|
|
|
|
|
54
|
|
|
8
|
2
|
|
|
2
|
|
883
|
use Template::Plugin; |
|
|
2
|
|
|
|
|
3477
|
|
|
|
2
|
|
|
|
|
165
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter AudioFile::Info Template::Plugin); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = sprintf "%d", '$Revision$ ' =~ /(\d+)/; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
1
|
|
|
1
|
1
|
40
|
my ($class, $context, $file) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
19
|
my $self = $class->SUPER::new($file); |
|
20
|
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return $self; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
|
25
|
|
|
|
|
|
|
__END__ |
|
26
|
|
|
|
|
|
|
# Below is stub documentation for your module. You'd better edit it! |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Template::Plugin::AudioFile::Info - Template Toolkit plugin for |
|
31
|
|
|
|
|
|
|
AudioFile::Info |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
[% USE song = AudioFile.Info(file) %] |
|
36
|
|
|
|
|
|
|
Title: [% song.title %] |
|
37
|
|
|
|
|
|
|
Artist: [% song.artist %] |
|
38
|
|
|
|
|
|
|
Album: [% song.album %] (track [% song.track %]) |
|
39
|
|
|
|
|
|
|
Year: [% song.year %] |
|
40
|
|
|
|
|
|
|
Genre: [% song.genre %] |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Template::Plugin::AudioFile::Info is a Template Toolkit plugin module |
|
45
|
|
|
|
|
|
|
which provides an interface to the AudioFile::Info module. |
|
46
|
|
|
|
|
|
|
AudioFile::Info provides a simple way to extract various pieces of |
|
47
|
|
|
|
|
|
|
information from audio files (both MP3 and Ogg Vorbis files). |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Template::Plugin::AudioFile::Info is intended to be used from with |
|
52
|
|
|
|
|
|
|
a template that is going to be processed by the Template Toolkit. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
A simple template might look like the one in the Synopsis above. In |
|
55
|
|
|
|
|
|
|
this case you would need to define the C<file> variable in some way. |
|
56
|
|
|
|
|
|
|
The simplest option would be to use the C<tpage> program that comes |
|
57
|
|
|
|
|
|
|
with the Template Toolkit, like this (assuming the template is in |
|
58
|
|
|
|
|
|
|
a file called C<song.tt>). |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$ tpage --define file=some_song.mp3 song.tt |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
If you wanted to process each file in a directory thne you might |
|
63
|
|
|
|
|
|
|
write a Perl program that processed the template multiple times |
|
64
|
|
|
|
|
|
|
like this. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use Template; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $tt = Template->new; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
foreach (</my/song/directory/*>) { |
|
71
|
|
|
|
|
|
|
next unless /\.(ogg|mp3)$/i; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$tt->process('song.tt', { file => $_ }) |
|
74
|
|
|
|
|
|
|
or die $tt->error; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
There are, of course, many other ways to do it. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHODS |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 new |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Constructor for this object. Simply delegates to AudioFile::Info. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=over 4 |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L<Template> (the Template Toolkit) |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L<AudioFile::Info> |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Dave Cross, E<lt>dave@dave.org.ukE<gt> |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright 2003 by Dave Cross |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
108
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|