Lincoln D. Stein > MP3-PodcastFetch-1.04 > MP3::PodcastFetch::TagManager

Download:
MP3-PodcastFetch-1.04.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  6
Open  0
View/Report Bugs
Source   Latest Release: MP3-PodcastFetch-1.05

NAME ^

MP3::PodcastFetch::TagManager -- Handle differences among ID3 tag libraries

SYNOPSIS ^

 use MP3::PodcastFetch::TagManager;
 my $manager = MP3::PodcastFetch::TagManager->new();
 $manager->fix_tags('/tmp/podcasts/mypodcast.mp3',
                    { genre  => 'Podcast',
                      album  => 'My album',
                      artist => 'Lincoln Stein',
                      title  => 'Podcast #18' 
                    },
                    'auto');
  my $duration = $manager->get_duration('/tmp/podcasts/mypodcast.mp3');

DESCRIPTION ^

This is a utility class written for MP3::PodcastFetch. It papers over the differences between three Perl ID3 tagging modules, MP3::Info, MP3::Tag and Audio::TagLib. No other tagging libraries are currently supported.

Main Methods

The following methods are intended for public consumption.

$manager = MP3::PodcastFetch::TagManager->new();

Create a new manager object. At any time there can only be one such object. Attempts to create new objects will retrieve the original object.

$manager->fix_tags($filename,$tag_hash,$upgrade_type)

Attempt to write the tags from the keys and values contained in $tag_hash. $filename is a path to a valid MP3 file. $tag_hash is a hash reference containing one or more of the keys:

 genre
 title
 album
 artist
 comment
 year

$upgrade_type indicates what type of tag to write, and must be one of:

 id3v1
 id3v2.3
 id3v2.4
 auto

These will attempt to write ID3 tags at the indicated level. "auto" attempts to write tags at the highest possible leve. Whether the manager will be able to comply depends on which tagging modules are present. For example, MP3::Tag can write ID3v2.3 and ID3v1 tags, but not ID3v2.4.

You should place this method in an eval {}, as errors are indicated by raising a die() exception.

$duration = $manager->get_duration($filename)

Get the duration of the indicated MP3 file using whatever library is available. Returns undef if no tag library is available.

Internal Methods & Functions.

The following methods are used internally, and may be overridden for further functionality.

$seconds = MP3::PodcastFetch::TagManager::get_duration_from_mp3info($filename)

Get the duration using MP3::Info. Note that this is a function, not a method.

$seconds = MP3::PodcastFetch::TagManager::get_duration_from_audiotaglib($filename)

Get the duration using Audio::Taglib. Note that this is a function, not a method.

$seconds = MP3::PodcastFetch::TagManager::get_duration_from_mp3tag($filename)

Get the duration using MP3::Tag. Note that this is a function, not a method.

$coderef = $manager->load_tag_fixer_code($upgrade_type)

Return a coderef to the appropriate function for updating the tag.

$result = $manager->load_mp3_tag_lib =item $result = $manager->load_audio_tag_lib =item $result = $manager->load_mp3_info_lib;

These methods attempt to load the corresponding tagging libraries, returning true if successful.

MP3::PodcastFetch::TagManager::upgrade_to_ID3v24($filename,$tags) =item MP3::PodcastFetch::TagManager::upgrade_to_ID3v23($filename,$tags) =item MP3::PodcastFetch::TagManager::upgrade_to_ID3v1($filename,$tags)

These functions (not methods) update the tags of $filename to the requested level.

BUGS ^

The architecture of this module was poorly thought out. It is currently difficult to extend. There should be a single virtual base class which autoloads implementors dynamically.

SEE ALSO ^

podcast_fetch.pl, MP3::PodcastFetch, MP3::PodcastFetch::Feed::Channel, MP3::PodcastFetch::Feed::Item, MP3::PodcastFetch::XML::SimpleParser

AUTHOR ^

Lincoln Stein <lstein@cshl.org>.

Copyright (c) 2006 Lincoln Stein

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.

syntax highlighting: