[AGRUNDMA - Fri Jun 18 15:30:29 2004]:
Show quoted text> Thanks, the module now runs without any errors. However, now I am
> trying to use the following code which is returning no results. It
> gets the RDF data from MB just fine, but doesn't appear to be
> parsing it properly.
Hmm.. did you add MBE_AlbumGetAmazonCoverartURL to your export list for
MusicBrainz::Queries?
I made a quick change to the getalbum.t test (attached) and ran in it on
a FreeBSD 4.6-STABLE box with perl 5.8.4 with the following results.
-- getalbum.out --
1..1
MusicBrainz::Client version: 0.08
MusicBrainz::Queries version: 0.07
libmusicbrainz version: 2.1.1
AlbumId: cb36140d-2202-4170-8649-c2e1c20d9d96
Name: Mind Fruit
Cover URL:
http://images.amazon.com/images/P/B000002JPG.01.MZZZZZZZ.jpg
NumTracks: 10
Track: It's A Fine Day
TrackId : bc47584e-9f79-4851-bdac-b6d5224c07f8
TrackNum : 1
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: I Talk To The Wind
TrackId : 53f0c7be-50f1-42fa-aaff-f200544b66c1
TrackNum : 2
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: Flow
TrackId : d088d101-21ff-4701-bfa6-aa845890990c
TrackNum : 3
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: Stars In My Pocket
TrackId : a28dd509-bee0-4e6b-a942-63c07ae6e970
TrackNum : 4
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: Sea People
TrackId : ae25fb46-5366-4d7c-9ee0-57d3d77282d7
TrackNum : 5
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: Evolution
TrackId : 7aabbee0-a4c0-417d-9533-2a62af29ae94
TrackNum : 6
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: Into This Universe
TrackId : 61cde77a-b00f-4263-b0da-1786f2c61f81
TrackNum : 7
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: Up
TrackId : 02d311b8-0dd6-4a15-9416-62174a17cc67
TrackNum : 8
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: Alzir
TrackId : 20c62fa0-2f35-4a73-8779-ebd610a9400c
TrackNum : 9
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
Track: Outro
TrackId : c49f1c13-3587-4389-81a0-470a179571a2
TrackNum : 10
TrackArtist : Opus III
ArtistId : 89240fa8-7e01-490f-8b4c-59f3f488eec6
ok 1
-- end --
BEGIN { $| =1; print "1..1\n"; }
END { print "not ok 1\n" unless $loaded; }
#
# $Id$
#
use strict;
use MusicBrainz::Client qw(MB_CDINDEX_ID_LEN);
use MusicBrainz::Queries qw(MBQ_GetAlbumById
MBQ_GetCDInfoFromCDIndexId
MBS_SelectAlbum
MBE_AlbumGetAlbumId
MBE_AlbumGetAlbumName
MBE_AlbumGetAmazonCoverartURL
MBE_AlbumGetNumTracks
MBE_AlbumGetArtistId
MBE_AlbumGetArtistName
MBE_AlbumGetTrackName
MBE_AlbumGetTrackId
MBE_AlbumGetTrackList);
#use constant ID => "dd4ff740-2a73-444d-8b55-d16fde79f429";
use constant ID => "cb36140d-2202-4170-8649-c2e1c20d9d96";
use constant MB_SERVER => "mm.musicbrainz.org";
use constant MB_PORT => 80;
use constant MB_DEBUG => 0;
use constant MB_DEPTH => 4;
my $mb = new MusicBrainz::Client();
if( $^O eq "MSWin32" )
{
$mb->WSAInit();
}
# Tell the client library to return data in ISO8859-1 and not UTF-8
$mb->use_utf8(0);
# Tell the server to return 10 items.
$mb->set_max_items(10);
# Set the proper server to use. Defaults to mm.musicbrainz.org:80
$mb->set_server(MB_SERVER, MB_PORT);
# Check to see if the debug env var has been set
$mb->set_debug(MB_DEBUG);
# Tell the server to only return 2 levels of data, unless the MB_DEPTH var
# is set
$mb->set_depth(MB_DEPTH);
printf("MusicBrainz::Client version: %s\n", $MusicBrainz::Client::VERSION);
printf("MusicBrainz::Queries version: %s\n", $MusicBrainz::Queries::VERSION);
printf("libmusicbrainz version: %d.%d.%d\n", $mb->get_version());
print "\n";
# Execute the MB_GetALbumById or a GetCDInfoFromCDIndexId query
my $ret;
if( length(ID) != MB_CDINDEX_ID_LEN ) {
$ret = $mb->query_with_args( MBQ_GetAlbumById, [ ID ]);
} else {
$ret = $mb->query_with_args( MBQ_GetCDInfoFromCDIndexId, [ ID ]);
}
if( !$ret) {
print "Query failed: ", $mb->get_query_error(), "\n";
exit(0);
}
# Select the first album
$mb->select1(MBS_SelectAlbum, 1);
my $data;
# Pull back the album id to see if we got the album
unless( $data = $mb->get_result_data( MBE_AlbumGetAlbumId ) ) {
print "Album not found.\n";
exit(0);
}
print " AlbumId: ", $mb->get_id_from_url( $data ) || "", "\n";
# Extract the album name
if( $data = $mb->get_result_data( MBE_AlbumGetAlbumName ) ) {
print " Name: ", $data, "\n";
}
if( $data = $mb->get_result_data( MBE_AlbumGetAmazonCoverartURL ) ) {
print " Cover URL: ", $data, "\n";
}
# Extract the number of tracks
my $num_tracks = $mb->get_result_int( MBE_AlbumGetNumTracks );
if( $num_tracks > 0 && $num_tracks < 100 ) {
print " NumTracks: ", $num_tracks, "\n";
}
# Check to see if there is more than one artist for this album
my $is_multiple_artist = 0;
for(my $i = 1; $i <= $num_tracks; $i++) {
unless( $data = $mb->get_result_data1( MBE_AlbumGetArtistId, $i ) ) {
next;
}
my $temp = $data if( $i == 1 );
if( $temp eq $data ) {
$is_multiple_artist = 1;
last;
}
}
unless( $is_multiple_artist ) {
# Extract the artist name from the album
if( $data = $mb->get_result_data1( MBE_AlbumGetArtistName, 1 ) ){
print "AlbumArtist: ", $data, "\n";
}
if( $data = $mb->get_result_data1( MBE_AlbumGetArtistId, 1 ) ) {
print "AlbumId : ", $data, "\n";
}
}
print "\n";
for( my $i = 1; $i <= $num_tracks; $i++ ) {
# Extract the track name from the album.
if( $data = $mb->get_result_data1( MBE_AlbumGetTrackName, $i ) ) {
print "Track: ", $data, "\n";
} else {
next;
}
# Extract the album id from the track. Just use the first album that
# this track appreas on
if( $data = $mb->get_result_data1( MBE_AlbumGetTrackId, $i ) ) {
print "TrackId : ", $mb->get_id_from_url($data) || "", "\n";
# Extract the track number
my $track_num = $mb->get_ordinal_from_list(MBE_AlbumGetTrackList, $data);
if( $track_num > 0 && $track_num < 100 ) {
print "TrackNum : ", $track_num, "\n";
}
}
# If its a multiple artist album, print out the artist for each track
if( $is_multiple_artist ) {
# Extract the artist name from this track
if( $data = $mb->get_result_data1( MBE_AlbumGetArtistName, $i ) ) {
print "TrackArtist : ", $data, "\n";
}
if( $data = $mb->get_result_data1( MBE_AlbumGetArtistId, $i ) ) {
print "ArtistId : ", $mb->get_id_from_url($data) || "", "\n";
}
}
print "\n";
}
if( $^O eq "MSWin32" )
{
$mb->WSAStop();
}
our $loaded = 1;
print "ok 1\n";