tunepimpSection: User Contributed Perl Documentation (3)Updated: 2004-03-12 |
tunepimpSection: User Contributed Perl Documentation (3)Updated: 2004-03-12 |
use MusicBrainz::Tunepimp::tunepimp;
my $tp = MusicBrainz::Tunepimp::tunepimp->new("My App", "1.0");
MusicBrainz (musicbrainz.org) is a free, community music metadatabase. The MusicBrainz Tunepimp library enables applications to fingerprint, identify, tag, and rename audio files based on the corresponding MusicBrainz data. See http://www.musicbrainz.org/tagger/index.html for more information.
This module is built on the C wrapper interface to Tunepimp; all of the functions such as "tp_GetStatus" have been transformed into Perl methods by removing the ``tp_'' (or ``tr_'', or ``md_'' etc) prefix, placing the method into the appropriate Perl class, and changing the first character of the method name to lower case (except for ``TRM...'' which remains in upper case). Hence, if you understand the Tunepimp documentation and know about "tr_GetFileName", you'll know it's now in the ``track'' class and is called "getFileName".
Hence here I'll just describe how this Perl module differs from the C wrapper interface.
($num_below_threshold, $recognized)
= $tp->getRecognizedFileList($threshold);
printf "%d of %d recognized files are below %d%% similarity\n",
$num_below_threshold, scalar(@$recognized),
$threshold;
print "The IDs of the recognized files are @$recognized\n";
# This calls $tunepimp->getDestDir
$dir = $tunepimp->destDir;
# This calls both getDestDir and setDestDir; it
# both sets a new value and returns the old one.
$olddir = $tunepimp->destDir($newdir);
Any pair of get / set methods are implemented as a combined method here. The name of the combined method is that of the get / set, with ``Get'' or ``Set'' removed, and the first character then changed to lower case (except for ``TRM...'').
All the getters and setters handle a single value at a time, except for ``proxy'', ``server'' and ``userInfo'', which all deal with a pair of values.
($type, $results) = $track->getResults;
for my $result (@$results)
{
...;
}
Each element of $results is a plain hash reference containing the relevant fields. Some of the fields may themselves be hash references, e.g. for a "eTrackList" result you can do $$result{album}{artist}{name}.
For the Perl interface however we'll provide separate ``get'' and ``set'' methods, then add combined get/set methods over the top of those.
In other words, these all work:
# Uses $number
$name = MusicBrainz::Tunepimp::metadata->getAlbumTypeNameFromNumber($number);
# Uses $metadata->getAlbumType
$name = $metadata->getAlbumTypeNameFromNumber;
# Uses $number
$name = $metadata->getAlbumTypeNameFromNumber($number);
The same applies to "getAlbumStatusNameFromNumber" / "getAlbumStatus".
These correspond to the value returned by "$tunepimp->getError" or "$track->getError".
These are the values returned by the ``status'' callback (see getStatus, setStatusCallback, getStatusCallback).
These correspond to the value returned by "$track->getStatus".
These correspond to the ``type'' value returned by "$track->getResults".
Use the export tag ``:all'' to export everything.
Nothing is exported by default.
The MusicBrainz Tagger: http://www.musicbrainz.org/tagger/index.html
MusicBrainz mailing lists: http://www.musicbrainz.org/list.html
Other Perl code (available from CPAN): "MusicBrainz::Client", "MusicBrainz::Client::Simple"
The following methods are out of bounds: "setStatusCallback", "getStatusCallback", "setNotifyCallback", "getNotifyCallback". Don't use them. They don't work. They probably never will. Instead, please use only the ``polling'' version to retrieve callback information, like so:
while (my ($type, $fileid) = $tunepimp->getNotification)
{
...;
}
while (defined (my $status = $tunepimp->getStatus))
{
...;
}
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.