MP3::Find::Base - Base class for MP3::Find backends
package MyFinder; use base 'MP3::Find::Base'; sub search { my $self = shift; my ($query, $dirs, $sort, $options) = @_; # do something to find and sort the mp3s... my @results = do_something(...); return @results; } package main; my $finder = MyFinder->new; # see MP3::Find for details about %options print "$_\n" foreach $finder->find_mp3s(\%options);
This is the base class for the classes that actually do the searching and sorting for MP3::Find.
Really simple constructor. If you pass it a hash of options, it will hang on to them for you.
This is the one you should override in your subclass. If you don't, the base class search method will croak.
search
The search method is called by the find_mp3s method with the following arguments: the finder object, a hashref of query parameters, an arrayref of directories to search, and a hashref of miscellaneous options.
find_mp3s
The search method should return a list of hashrefs representing the results of the search. Each hashref should have the following keys (all except FILENAME are derived from the keys returned by the get_mp3tag and get_mp3Info functions from MP3::Info):
FILENAME
get_mp3tag
get_mp3Info
FILENAME TITLE ARTIST ALBUM YEAR COMMENT GENRE TRACKNUM VERSION -- MPEG audio version (1, 2, 2.5) LAYER -- MPEG layer description (1, 2, 3) STEREO -- boolean for audio is in stereo VBR -- boolean for variable bitrate BITRATE -- bitrate in kbps (average for VBR files) FREQUENCY -- frequency in kHz SIZE -- bytes in audio stream OFFSET -- bytes offset that stream begins SECS -- total seconds MM -- minutes SS -- leftover seconds MS -- leftover milliseconds TIME -- time in MM:SS COPYRIGHT -- boolean for audio is copyrighted PADDING -- boolean for MP3 frames are padded MODE -- channel mode (0 = stereo, 1 = joint stereo, -- 2 = dual channel, 3 = single channel) FRAMES -- approximate number of frames FRAME_LENGTH -- approximate length of a frame VBR_SCALE -- VBR scale from VBR header
The method that should be called by the program doing the searching.
See MP3::Find for an explanation of the options that can be passed to find_mp3s.
More format codes? Possibly look into using String::Format
MP3::Find, MP3::Find::Filesystem, MP3::Find::DB
See MP3::Info for more information about the fields you can search and sort on.
Peter Eichman <peichman@cpan.org>
Copyright (c) 2006 by Peter Eichman. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MP3::Find, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MP3::Find
CPAN shell
perl -MCPAN -e shell install MP3::Find
For more information on module installation, please visit the detailed CPAN module installation guide.