Template-Plugin-MP3-Tag

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension Template::Plugin::MP3::Tag.

0.01  Sat Apr 15 04:29:10 2006
	- original version; created by h2xs 1.23 with options
		-XAn Template::Plugin::MP3::Tag

Makefile.PL  view on Meta::CPAN

use 5.008002;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    NAME              => 'Template::Plugin::MP3::Tag',
    VERSION_FROM      => 'lib/Template/Plugin/MP3/Tag.pm', # finds $VERSION
    PREREQ_PM         => {}, # e.g., Module::Name => 1.1
    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM  => 'lib/Template/Plugin/MP3/Tag.pm', # retrieve abstract from module
       AUTHOR         => 'A. U. Thor <travail@localdomain>') : ()),
);

README  view on Meta::CPAN

Template-Plugin-MP3-Tag version 0.01
==============================================================================

To install the Template::Plugin::MP3::Tag module you do stereotype things:

perl Makefile.PL
make
make test
make install (as root)

If you find some errors while doing this, please send me
an email describing the problems.

In the directory 'script' and 'template', you will find script 'sample.pl' and
'sample.tt', how to use this module.

And perldoc MP3::Tag for methods implemented this module.

Thank you for using this module.

lib/Template/Plugin/MP3/Tag.pm  view on Meta::CPAN

package Template::Plugin::MP3::Tag;

# ----------------------------------------------------------------------
# $Id: Tag.pm,v 1.7 2006/04/24 03:30:05 travail Exp $
# ----------------------------------------------------------------------

use 5.008002;
use strict;
use warnings;
use vars qw ( $VERSION $AUTOLOAD );
use base qw( Template::Plugin );
use MP3::Tag ();
use Template::Plugin;

my $ETYPE = 'plugin.mp3_tag';
$VERSION = '0.01';

sub new {
    my ( $class, $context, $file ) = @_;

    -e $file || $context->throw( $ETYPE, "File '$file' does not exist" );

    my $mp3_tag = MP3::Tag->new( $file )
        || $context->throw( $ETYPE, "Can't create MP3::Tag object for mp3 file '$file'" );

    bless {
        _CONTEXT => $context,
        _FILE    => $file,
        _MP3_TAG => $mp3_tag
    }, $class;
}

sub AUTOLOAD {
    my $self = shift;

lib/Template/Plugin/MP3/Tag.pm  view on Meta::CPAN


    return $self->autoinfo->{year};
}

1;

__END__

=head1 NAME

Template::Plugin::MP3::Tag - Interface to the MP3::Tag Module

=head1 SYNOPSIS

    [% USE tag = MP3("path_to_mp3_file") %]

    [% tag.title %]
    [% tag.album %]

    # perldoc MP3::Tag for more ideas

=head1 DESCRIPTION

C<Template::Plugin::MP3::Tag> provides a simple wrapper for using
C<MP3::Tag> in object oriented mode; see L<MP3::Tag> for more
details.

Although C<Template::Plugin::MP3> can fetch MP3 files, but it Supports only ID3v1.
When you have to fetch MP3 files ID3v2, I recommend you to use this module.

=head1 CONSTRUCTIR

C<Template::Plugin::MP3::Tag> tales a filename as primary argument:

    [% USE tag = MP3::Tag("path_to_mp3file") %]
    [% tag.album %] 
    [% tag.artist %]

    # If you need encode the tag information,
    # code just like below.

    [% tag.album.jcode.euc %]
    [% tag.artist.jcode.euc %]

=head1 SEE ALSO

L<Template::Plugin>, L<MP3::Tag>

=head1 AUTHOR

Tomoyuki SAWA, E<lt>travail@cabane.no-ip.orgE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2006 by Tomoyuki SAWA

This library is free software; you can redistribute it and/or modify

t/00-load.t  view on Meta::CPAN

use Test::More tests => 4;
use FindBin;
use Template;

use_ok('Template');
use_ok('MP3::Tag');
ok( -e 't/test.mp3', 'MP3 file exist' );
ok( -e 't/template/artist.tt', 'Template File exist' );

t/template/album.tt  view on Meta::CPAN

[% USE mp3 = MP3::Tag( mp3_file ) %][% mp3.album %]

t/template/artist.tt  view on Meta::CPAN

[% USE mp3 = MP3::Tag( mp3_file ) %][% mp3.artist %]

t/template/comment.tt  view on Meta::CPAN

[% USE mp3 = MP3::Tag( mp3_file ) %][% mp3.comment %]

t/template/genre.tt  view on Meta::CPAN

[% USE mp3 = MP3::Tag( mp3_file ) %][% mp3.genre %]

t/template/title.tt  view on Meta::CPAN

[% USE mp3 = MP3::Tag( mp3_file ) %][% mp3.title %]

t/template/year.tt  view on Meta::CPAN

[% USE mp3 = MP3::Tag( mp3_file ) %][% mp3.year %]

template/sample.tt  view on Meta::CPAN

[% FOREACH filename = files %]
[% USE tag = MP3::Tag(filename) %]
[% USE Jcode %]
[% tag.album.jcode.euc %]
[% tag.artist.jcode.euc %]
[% tag.song.jcode.euc %]
[% tag.track.jcode.euc %]
[% tag.title.jcode.euc %]
[% tag.genre.jcode.euc %]
[% tag.year.jcode.euc %]
[% tag.commen.jcode.euc %]
[% END %]



( run in 0.580 second using v1.01-cache-2.11-cpan-0d8aa00de5b )