| 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 | ▶ | use 5.008002; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 6 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 6 | ▶ | use vars qw ( $VERSION $AUTOLOAD ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 6 | ▶ | use base qw( Template::Plugin ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 0 | ▶ | use MP3::Tag (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 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__ | ||