MP3::PodcastFetch::TagManager -- Handle differences among ID3 tag libraries
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');
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.
The following methods are intended for public consumption.
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.
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.
Get the duration of the indicated MP3 file using whatever library is available. Returns undef if no tag library is available.
The following methods are used internally, and may be overridden for further functionality.
Get the duration using MP3::Info. Note that this is a function, not a method.
Get the duration using Audio::Taglib. Note that this is a function, not a method.
Get the duration using MP3::Tag. Note that this is a function, not a method.
Return a coderef to the appropriate function for updating the tag.
These methods attempt to load the corresponding tagging libraries, returning true if successful.
These functions (not methods) update the tags of $filename to the requested level.
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.
podcast_fetch.pl, MP3::PodcastFetch, MP3::PodcastFetch::Feed::Channel, MP3::PodcastFetch::Feed::Item, MP3::PodcastFetch::XML::SimpleParser
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.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install MP3::PodcastFetch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MP3::PodcastFetch
CPAN shell
perl -MCPAN -e shell install MP3::PodcastFetch
For more information on module installation, please visit the detailed CPAN module installation guide.