WebService-MusicBrainz-0.93/0000755000175000017500000000000011304125306015224 5ustar bfaistbfaistWebService-MusicBrainz-0.93/Makefile.PL0000444000175000017500000000122211304125306017171 0ustar bfaistbfaist# Note: this file was auto-generated by Module::Build::Compat version 0.2808_01 require 5.7.0; use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'WebService::MusicBrainz', 'VERSION_FROM' => 'lib/WebService/MusicBrainz.pm', 'PREREQ_PM' => { 'Class::Accessor' => '0.30', 'LWP::UserAgent' => '2.0', 'Test::More' => '0.88', 'URI' => '1.35', 'XML::LibXML' => '1.63' }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], 'PL_FILES' => {} ) ; WebService-MusicBrainz-0.93/t/0000755000175000017500000000000011304125306015467 5ustar bfaistbfaistWebService-MusicBrainz-0.93/t/Track.t0000444000175000017500000000161711304125306016723 0ustar bfaistbfaist# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl WebService-MusicBrainz.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use strict; use Test::More; BEGIN { use_ok('WebService::MusicBrainz::Track') }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $sleep_duration = 2; my $ws = WebService::MusicBrainz::Track->new(); ok( $ws, 'create WebService::MusicBrainz::Track object' ); my $wsde = WebService::MusicBrainz::Track->new(HOST => 'de.musicbrainz.org'); my $wsde_query = $wsde->query(); ok( $wsde_query->{_baseurl} =~ m/de\.musicbrainz\.org/, 'create WebService::MusicBrainz::Track object/altername host' ); sleep($sleep_duration); done_testing(); WebService-MusicBrainz-0.93/t/ReleaseGroup.t0000444000175000017500000000166211304125306020254 0ustar bfaistbfaist# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl WebService-MusicBrainz.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use strict; use Test::More; BEGIN { use_ok('WebService::MusicBrainz::ReleaseGroup') }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $sleep_duration = 2; my $ws = WebService::MusicBrainz::ReleaseGroup->new(); ok( $ws, 'create WebService::MusicBrainz::ReleaseGroup object' ); my $wsde = WebService::MusicBrainz::ReleaseGroup->new(HOST => 'de.musicbrainz.org'); my $wsde_query = $wsde->query(); ok( $wsde_query->{_baseurl} =~ m/de\.musicbrainz\.org/, 'create WebService::MusicBrainz::ReleaseGroup object/altername host' ); sleep($sleep_duration); done_testing(); WebService-MusicBrainz-0.93/t/Label.t0000444000175000017500000000162011304125306016670 0ustar bfaistbfaist# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl WebService-MusicBrainz.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use strict; use Test::More; BEGIN { use_ok('WebService::MusicBrainz::Label') }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $sleep_duration = 2; my $ws = WebService::MusicBrainz::Label->new(); ok( $ws, 'create WebService::MusicBrainz::Label object' ); my $wsde = WebService::MusicBrainz::Label->new(HOST => 'de.musicbrainz.org'); my $wsde_query = $wsde->query(); ok( $wsde_query->{_baseurl} =~ m/de\.musicbrainz\.org/, 'create WebService::MusicBrainz::Label object/altername host' ); sleep($sleep_duration); done_testing(); WebService-MusicBrainz-0.93/t/Release.t0000444000175000017500000006651411304125306017246 0ustar bfaistbfaist# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl WebService-MusicBrainz.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use strict; use Test::More; BEGIN { use_ok('WebService::MusicBrainz::Release') }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $sleep_duration = 2; my $ws = WebService::MusicBrainz::Release->new(); ok( $ws, 'create WebService::MusicBrainz::Release object' ); my $wsde = WebService::MusicBrainz::Release->new(HOST => 'de.musicbrainz.org'); my $wsde_query = $wsde->query(); ok( $wsde_query->{_baseurl} =~ m/de\.musicbrainz\.org/, 'create WebService::MusicBrainz::Release object/altername host' ); my $rel_title = $ws->search({ TITLE => 'Van Halen' }); ok($rel_title, 'release by title'); my $rel_title_rel_list = $rel_title->release_list(); ok($rel_title_rel_list, 'release by title RELEASE LIST'); ok($rel_title_rel_list->count() > 5, 'release by title rel list COUNT'); foreach my $release (@{ $rel_title_rel_list->releases() }) { if($release->id() eq "0d5f0dc2-b597-4b6c-9a6f-49b70b8e23b6") { ok($release->type() eq "Album Official", 'release by title rel TYPE'); ok($release->score() > 90, 'release by title rel SCORE'); ok($release->title() eq "Van Halen", 'release by title rel TITLE'); ok($release->text_rep_language() eq "ENG", 'release by title rel LANG'); ok($release->text_rep_script() eq "Latn", 'release by title rel SCRIPT'); ok($release->asin() eq "B00004Y6O9", 'release by title rel ASIN'); ok($release->artist()->name() eq "Van Halen", 'release by title rel artist NAME'); ok($release->disc_list()->count() > 10, 'release by title rel disc list COUNT'); ok($release->track_list()->count() > 10, 'release by title rel track list COUNT'); my $last_date = "0000-00-00"; my $sorted = 1; foreach my $event (@{ $release->release_event_list()->events() }) { if($last_date le $event->date()) { $sorted = 1; } else { $sorted = 0; last; } $last_date = $event->date(); } ok($sorted == 1,'release by title sorted release events'); } } sleep($sleep_duration); my $rel_discid = $ws->search({ DISCID => 'Qb6ACLJhzNM46cXKVZSh3qMOv6A-' }); ok( $rel_discid, 'release by discid'); my $rel_discid_release = $rel_discid->release(); ok( $rel_discid_release, 'release by disc RELEASE'); ok( $rel_discid_release->title() eq "Van Halen", 'release by disc TITLE'); ok( $rel_discid_release->text_rep_language() eq "ENG", 'release by disc LANG'); ok( $rel_discid_release->text_rep_script() eq "Latn", 'release by disc SCRIPT'); ok( $rel_discid_release->artist()->name() eq "Van Halen", 'release by disc artist NAME'); ok( $rel_discid_release->artist()->sort_name() eq "Van Halen", 'release by disc artist SORT NAME'); foreach my $event (@{ $rel_discid_release->release_event_list()->events() }) { if($event->catalog_number() && $event->catalog_number() eq "9362-47737-2") { ok($event->date() eq "2000", 'rel disc rel eventlist event DATE'); ok($event->country() eq "US", 'rel disc rel eventlist event COUNTRY'); ok($event->barcode() eq "093624773726", 'rel disc rel eventlist event BARCODE'); last; } } ok( $rel_discid_release->disc_list()->count() > 10, 'release by disc disc list COUNT'); foreach my $track (@{ $rel_discid_release->track_list()->tracks() }) { if($track->id() eq "619f18ad-b7c8-4b0e-826e-585de75b33f8") { ok($track->title() eq "Eruption", 'release by disc track list track TITLE'); ok($track->duration() eq "102626", 'release by disc track list track DURATION'); } } my $rel_artist_response = $ws->search({ ARTIST => 'Van Halen' }); ok( $rel_artist_response, 'rel by artist'); foreach my $release (@{ $rel_artist_response->release_list()->releases() }) { if($release->id() eq "cac41921-bd04-4ceb-b41c-ca9eb495c0f6") { ok( $release->type() eq "Album Official", 'rel by artist release TYPE'); ok( $release->score() > 90, 'rel by artist release SCORE'); ok( $release->title() eq "5150", 'rel by artist release TITLE'); ok( $release->text_rep_language() eq "ENG", 'rel by artist release LANG'); ok( $release->text_rep_script() eq "Latn", 'rel by artist release SCRIPT'); ok( $release->asin() eq "B000002L99", 'rel by artist release ASIN'); ok( $release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel by artist release ARTIST'); ok( $release->artist()->name() eq "Van Halen", 'rel by artist release artist NAME'); ok( $release->disc_list()->count() > 4, 'rel by artist release artist disc list COUNT'); ok( $release->track_list()->count() > 8, 'rel by artist release artist track list COUNT'); last; } } sleep($sleep_duration); my $rel_artistid_response = $ws->search({ ARTISTID => 'b665b768-0d83-4363-950c-31ed39317c15' }); ok( $rel_artistid_response, 'rel by artistid'); foreach my $release (@{ $rel_artistid_response->release_list()->releases() }) { if($release->id() eq "cac41921-bd04-4ceb-b41c-ca9eb495c0f6") { ok( $release->type() eq "Album Official", 'rel by artistid release TYPE'); ok( $release->score() > 90, 'rel by artistid release SCORE'); ok( $release->title() eq "5150", 'rel by artistid release TITLE'); ok( $release->text_rep_language() eq "ENG", 'rel by artistid release LANG'); ok( $release->text_rep_script() eq "Latn", 'rel by artistid release SCRIPT'); ok( $release->asin() eq "B000002L99", 'rel by artistid release ASIN'); ok( $release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel by artistid release ARTIST'); ok( $release->artist()->name() eq "Van Halen", 'rel by artistid release artistid NAME'); ok( $release->disc_list()->count() > 4, 'rel by artistid release artistid disc list COUNT'); ok( $release->track_list()->count() > 8, 'rel by artistid release artistid track list COUNT'); last; } } my $rel_reltypes_response = $ws->search({ ARTIST => 'Van Halen', RELEASETYPES => 'Bootleg' }); ok( $rel_reltypes_response, 'rel by reltyppes'); foreach my $release (@{ $rel_reltypes_response->release_list()->releases() }) { if($release->id() eq "3ae1eae2-c6f2-4c08-9805-ccfcdc7d2a4b") { ok($release->score() > 90, 'rel by reltypes SCORE'); ok($release->type() eq "Live Bootleg", 'rel by reltypes TYPE'); ok($release->title() eq "Secret Gig", 'rel by reltypes TITLE'); ok( $release->text_rep_language() eq "ENG", 'rel by reltypes release LANG'); ok( $release->text_rep_script() eq "Latn", 'rel by reltypes release SCRIPT'); ok( $release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel by reltypes release ARTIST'); ok( $release->artist()->name() eq "Van Halen", 'rel by reltypes release artistid NAME'); ok( $release->disc_list()->count() > 0, 'rel by reltypes disc list COUNT'); ok( $release->track_list()->count() > 3, 'rel by reltypes track list COUNT'); last; } } sleep($sleep_duration); my $rel_count_response = $ws->search({ ARTIST => 'Van Halen', COUNT => 10 }); ok( $rel_count_response, 'rel by count'); foreach my $release (@{ $rel_count_response->release_list()->releases() }) { if($release->id() eq "006b0c0e-2e35-49a4-9c2f-68770c6c1bde") { ok($release->score() > 90, 'rel by count SCORE'); ok($release->type() eq "Album Official", 'rel by count TYPE'); ok($release->title() eq "OU812", 'rel by count TITLE'); ok( $release->text_rep_language() eq "ENG", 'rel by count release LANG'); ok( $release->text_rep_script() eq "Latn", 'rel by count release SCRIPT'); ok( $release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel by count release ARTIST'); ok( $release->artist()->name() eq "Van Halen", 'rel by count release artistid NAME'); ok( $release->disc_list()->count() > 2, 'rel by count disc list COUNT'); ok( $release->track_list()->count() == 10, 'rel by count track list COUNT'); last; } } my $rel_date_response = $ws->search({ ARTIST => 'Van Halen', DATE => '1980' }); ok( $rel_date_response, 'rel by date'); foreach my $release (@{ $rel_date_response->release_list()->releases() }) { if($release->id() eq "71ee7c4a-8da9-438d-a344-7626b91005dc") { ok($release->score() > 90, 'rel by date SCORE'); ok($release->type() eq "Album Official", 'rel by date TYPE'); ok($release->title() eq "Women and Children First", 'rel by date TITLE'); ok( $release->text_rep_language() eq "ENG", 'rel by date release LANG'); ok( $release->text_rep_script() eq "Latn", 'rel by date release SCRIPT'); ok( $release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel by date release ARTIST'); ok( $release->artist()->name() eq "Van Halen", 'rel by date release artistid NAME'); ok( $release->disc_list()->count() > 5, 'rel by date disc list COUNT'); ok( $release->track_list()->count() > 8, 'rel by date track list COUNT'); foreach my $event (@{ $release->release_event_list()->events() }) { if($event->label() && $event->label() eq "Warner Music UK") { ok( $event->country() eq "GB", 'rel by date event COUNTRY'); ok( $event->date() eq "1980", 'rel by date event DATE'); last; } } last; } } sleep($sleep_duration); my $rel_asin_response = $ws->search({ ARTIST => 'Van Halen', ASIN => "B000002LEM" }); ok( $rel_asin_response, 'rel by asin'); foreach my $release (@{ $rel_asin_response->release_list()->releases() }) { if($release->id() eq "006b0c0e-2e35-49a4-9c2f-68770c6c1bde") { ok($release->score() > 90, 'rel by asin SCORE'); ok($release->type() eq "Album Official", 'rel by asin TYPE'); ok($release->title() eq "OU812", 'rel by asin TITLE'); ok($release->asin() eq "B000002LEM", 'rel by asin ASIN'); ok( $release->text_rep_language() eq "ENG", 'rel by asin release LANG'); ok( $release->text_rep_script() eq "Latn", 'rel by asin release SCRIPT'); ok( $release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel by asin release ARTIST'); ok( $release->artist()->name() eq "Van Halen", 'rel by asin release artistid NAME'); ok( $release->disc_list()->count() > 2, 'rel by asin disc list COUNT'); ok( $release->track_list()->count() == 10, 'rel by asin track list COUNT'); last; } } # TODO: Not working. MB bug? # my $rel_lang_response = $ws->search({ ARTIST => 'Van Halen', LANG => "ENG" }); # ok( $rel_lang_response, 'rel by lang'); # foreach my $release (@{ $rel_lang_response->release_list()->releases() }) { # if($release->id() eq "006b0c0e-2e35-49a4-9c2f-68770c6c1bde") { # ok($release->score() > 90, 'rel by lang SCORE'); # ok($release->type() eq "Album Official", 'rel by lang TYPE'); # ok($release->title() eq "OU812", 'rel by lang TITLE'); # ok($release->asin() eq "B000002LEM", 'rel by lang ASIN'); # ok( $release->text_rep_language() eq "ENG", 'rel by lang release LANG'); # ok( $release->text_rep_script() eq "Latn", 'rel by lang release SCRIPT'); # ok( $release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel by lang release ARTIST'); # ok( $release->artist()->name() eq "Van Halen", 'rel by lang release artistid NAME'); # ok( $release->disc_list()->count() > 2, 'rel by lang disc list COUNT'); # ok( $release->track_list()->count() == 10, 'rel by lang track list COUNT'); # last; # } # } # # sleep($sleep_duration); # # TODO: Not working. MB bug? # my $rel_script_response = $ws->search({ ARTIST => 'Van Halen', SCRIPT => "Latn" }); # ok( $rel_script_response, 'rel by script'); # foreach my $release (@{ $rel_script_response->release_list()->releases() }) { # if($release->id() eq "006b0c0e-2e35-49a4-9c2f-68770c6c1bde") { # ok($release->score() > 90, 'rel by script SCORE'); # ok($release->type() eq "Album Official", 'rel by script TYPE'); # ok($release->title() eq "OU812", 'rel by script TITLE'); # ok($release->script() eq "B000002LEM", 'rel by script ASIN'); # ok( $release->text_rep_scriptuage() eq "ENG", 'rel by script release LANG'); # ok( $release->text_rep_script() eq "Latn", 'rel by script release SCRIPT'); # ok( $release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel by script release ARTIST'); # ok( $release->artist()->name() eq "Van Halen", 'rel by script release artistid NAME'); # ok( $release->disc_list()->count() > 2, 'rel by script disc list COUNT'); # ok( $release->track_list()->count() == 10, 'rel by script track list COUNT'); # last; # } # } my $rel_limit_response = $ws->search({ ARTIST => 'Van Halen', LIMIT => "40" }); ok( $rel_limit_response, 'rel by limit'); ok( scalar(@{ $rel_limit_response->release_list()->releases() }) == 40, 'release limit'); my $rel_mbid_artist_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'artist' }); ok( $rel_mbid_artist_response, 'rel mbid inc artist'); my $rel_mbid_artist_release = $rel_mbid_artist_response->release(); ok( $rel_mbid_artist_release, 'rel mbid inc artist RELEASE'); ok( $rel_mbid_artist_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc artist release ID'); ok( $rel_mbid_artist_release->type() eq "Album Official", 'rel mbid inc artist release TYPE'); ok( $rel_mbid_artist_release->title() eq "1984", 'rel mbid inc artist release TITLE'); ok( $rel_mbid_artist_release->text_rep_language() eq "ENG", 'rel mbid inc artist release LANG'); ok( $rel_mbid_artist_release->text_rep_script() eq "Latn", 'rel mbid inc artist release SCRIPT'); ok( $rel_mbid_artist_release->artist()->id() eq "b665b768-0d83-4363-950c-31ed39317c15", 'rel mbid inc artist release artist ID'); ok( $rel_mbid_artist_release->artist()->type() eq "Group", 'rel mbid inc artist release artist TYPE'); ok( $rel_mbid_artist_release->artist()->name() eq "Van Halen", 'rel mbid inc artist release artist NAME'); ok( $rel_mbid_artist_release->artist()->sort_name() eq "Van Halen", 'rel mbid inc artist release artist SORT NAME'); sleep($sleep_duration); my $rel_mbid_counts_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'counts' }); ok( $rel_mbid_counts_response, 'rel mbid inc counts'); my $rel_mbid_counts_release = $rel_mbid_counts_response->release(); ok( $rel_mbid_counts_release, 'rel mbid inc counts RELEASE'); ok( $rel_mbid_counts_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc counts release ID'); ok( $rel_mbid_counts_release->type() eq "Album Official", 'rel mbid inc counts release TYPE'); ok( $rel_mbid_counts_release->title() eq "1984", 'rel mbid inc counts release TITLE'); ok( $rel_mbid_counts_release->text_rep_language() eq "ENG", 'rel mbid inc counts release LANG'); ok( $rel_mbid_counts_release->text_rep_script() eq "Latn", 'rel mbid inc counts release SCRIPT'); ok( $rel_mbid_counts_release->asin() eq "B00004Y6O3", 'rel mbid inc counts release ASIN'); ok( $rel_mbid_counts_release->release_event_list()->count() > 1 , 'rel mbid inc counts release release_info_list COUNT'); ok( $rel_mbid_counts_release->disc_list()->count() > 7, 'rel mbid inc counts release disc_list COUNT'); my $rel_mbid_events_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'release-events' }); ok( $rel_mbid_events_response, 'rel mbid inc events'); my $rel_mbid_events_release = $rel_mbid_events_response->release(); ok( $rel_mbid_events_release, 'rel mbid inc events RELEASE'); ok( $rel_mbid_events_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc events release ID'); ok( $rel_mbid_events_release->type() eq "Album Official", 'rel mbid inc events release TYPE'); ok( $rel_mbid_events_release->title() eq "1984", 'rel mbid inc events release TITLE'); ok( $rel_mbid_events_release->text_rep_language() eq "ENG", 'rel mbid inc events release LANG'); ok( $rel_mbid_events_release->text_rep_script() eq "Latn", 'rel mbid inc events release SCRIPT'); ok( $rel_mbid_events_release->asin() eq "B00004Y6O3", 'rel mbid inc events release ASIN'); foreach my $event (@{ $rel_mbid_events_release->release_event_list()->events() }) { if($event->barcode() eq "075992398527") { ok( $event->date() eq "1984-01-09", 'rel mbid inc events rel_event_list event DATE'); ok( $event->country() eq "US", 'rel mbid inc events rel_event_list event COUNTRY'); ok( $event->catalog_number() eq "9 23985-2", 'rel mbid inc events rel_event_list event CATALOG NUMBER'); ok( $event->format() eq "CD", 'rel mbid inc events rel_event_list event FORMAT'); last; } } sleep($sleep_duration); my $rel_mbid_discs_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'discs' }); ok( $rel_mbid_discs_response, 'rel mbid inc discs'); my $rel_mbid_discs_release = $rel_mbid_discs_response->release(); ok( $rel_mbid_discs_release, 'rel mbid inc discs RELEASE'); ok( $rel_mbid_discs_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc discs release ID'); ok( $rel_mbid_discs_release->type() eq "Album Official", 'rel mbid inc discs release TYPE'); ok( $rel_mbid_discs_release->title() eq "1984", 'rel mbid inc discs release TITLE'); ok( $rel_mbid_discs_release->text_rep_language() eq "ENG", 'rel mbid inc discs release LANG'); ok( $rel_mbid_discs_release->text_rep_script() eq "Latn", 'rel mbid inc discs release SCRIPT'); ok( $rel_mbid_discs_release->asin() eq "B00004Y6O3", 'rel mbid inc discs release ASIN'); foreach my $disc (@{ $rel_mbid_discs_release->disc_list()->discs() }) { if($disc->id() eq "RYubBCKHdNeT.M51Xv6hUeCuUjY-") { ok( $disc->sectors() eq "150400", 'rel mbid inc discs SECTORS'); last; } } my $rel_mbid_tracks_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'tracks' }); ok( $rel_mbid_tracks_response, 'rel mbid inc tracks'); my $rel_mbid_tracks_release = $rel_mbid_tracks_response->release(); ok( $rel_mbid_tracks_release, 'rel mbid inc tracks RELEASE'); ok( $rel_mbid_tracks_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc tracks release ID'); ok( $rel_mbid_tracks_release->type() eq "Album Official", 'rel mbid inc tracks release TYPE'); ok( $rel_mbid_tracks_release->title() eq "1984", 'rel mbid inc tracks release TITLE'); ok( $rel_mbid_tracks_release->text_rep_language() eq "ENG", 'rel mbid inc tracks release LANG'); ok( $rel_mbid_tracks_release->text_rep_script() eq "Latn", 'rel mbid inc tracks release SCRIPT'); ok( $rel_mbid_tracks_release->asin() eq "B00004Y6O3", 'rel mbid inc tracks release ASIN'); foreach my $track (@{ $rel_mbid_tracks_release->track_list()->tracks() }) { if($track->id() eq "77ee68a0-f28e-46ce-9751-2ec2c54943c6") { ok( $track->title() eq "Hot for Teacher", 'rel mbid inc tracks TITLE'); ok( $track->duration() eq "284600", 'rel mbid inc tracks DURATION'); last; } } sleep($sleep_duration); my $rel_mbid_relgroups_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'release-groups' }); ok( $rel_mbid_relgroups_response, 'rel mbid inc relgroups'); my $rel_mbid_relgroups_release = $rel_mbid_relgroups_response->release(); ok( $rel_mbid_relgroups_release, 'rel mbid inc relgroups RELEASE'); ok( $rel_mbid_relgroups_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc relgroups release ID'); ok( $rel_mbid_relgroups_release->type() eq "Album Official", 'rel mbid inc relgroups release TYPE'); ok( $rel_mbid_relgroups_release->title() eq "1984", 'rel mbid inc relgroups release TITLE'); ok( $rel_mbid_relgroups_release->text_rep_language() eq "ENG", 'rel mbid inc relgroups release LANG'); ok( $rel_mbid_relgroups_release->text_rep_script() eq "Latn", 'rel mbid inc relgroups release SCRIPT'); ok( $rel_mbid_relgroups_release->asin() eq "B00004Y6O3", 'rel mbid inc relgroups release ASIN'); ok( $rel_mbid_relgroups_release->release_group()->id() eq "5846f0c9-fec3-3b9e-a77c-fbe9a7bdf0e7", 'rel mbid inc relgroups ID'); ok( $rel_mbid_relgroups_release->release_group()->type() eq "Album", 'rel mbid inc relgroups TYPE'); ok( $rel_mbid_relgroups_release->release_group()->title() eq "1984", 'rel mbid inc relgroups TITLE'); my $rel_mbid_artistrels_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'artist-rels' }); ok( $rel_mbid_artistrels_response, 'rel mbid inc artistrels'); my $rel_mbid_artistrels_release = $rel_mbid_artistrels_response->release(); ok( $rel_mbid_artistrels_release, 'rel mbid inc artistrels RELEASE'); ok( $rel_mbid_artistrels_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc artistrels release ID'); ok( $rel_mbid_artistrels_release->type() eq "Album Official", 'rel mbid inc artistrels release TYPE'); ok( $rel_mbid_artistrels_release->title() eq "1984", 'rel mbid inc artistrels release TITLE'); ok( $rel_mbid_artistrels_release->text_rep_language() eq "ENG", 'rel mbid inc artistrels release LANG'); ok( $rel_mbid_artistrels_release->text_rep_script() eq "Latn", 'rel mbid inc artistrels release SCRIPT'); ok( $rel_mbid_artistrels_release->asin() eq "B00004Y6O3", 'rel mbid inc artistrels release ASIN'); ok( $rel_mbid_artistrels_release->relation_list()->target_type() eq "Artist", 'rel mbid inc artistrels release rellist TARGETTYPE'); foreach my $relation (@{ $rel_mbid_artistrels_release->relation_list()->relations() }) { if($relation->target() eq "802d37d5-0aaa-492e-b366-99f75e5a196f") { ok( $relation->type() eq "Vocal", 'rel mbid inc artistrels release TYPE'); ok( $relation->artist()->id() eq "802d37d5-0aaa-492e-b366-99f75e5a196f", 'rel mbid inc artistrels artist ID'); ok( $relation->artist()->name() eq "David Lee Roth", 'rel mbid inc artistrels artist NAME'); ok( $relation->artist()->sort_name() eq "Roth, David Lee", 'rel mbid inc artistrels artist SORTNAME'); ok( $relation->artist()->life_span_begin() eq "1955-10-10", 'rel mbid inc artistrels artist BEGIN'); last; } } sleep($sleep_duration); # label-rels # release-rels # track-rels my $rel_mbid_urlrels_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'url-rels' }); ok( $rel_mbid_urlrels_response, 'rel mbid inc urlrels'); my $rel_mbid_urlrels_release = $rel_mbid_urlrels_response->release(); ok( $rel_mbid_urlrels_release, 'rel mbid inc urlrels RELEASE'); ok( $rel_mbid_urlrels_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc urlrels release ID'); ok( $rel_mbid_urlrels_release->type() eq "Album Official", 'rel mbid inc urlrels release TYPE'); ok( $rel_mbid_urlrels_release->title() eq "1984", 'rel mbid inc urlrels release TITLE'); ok( $rel_mbid_urlrels_release->text_rep_language() eq "ENG", 'rel mbid inc urlrels release LANG'); ok( $rel_mbid_urlrels_release->text_rep_script() eq "Latn", 'rel mbid inc urlrels release SCRIPT'); ok( $rel_mbid_urlrels_release->asin() eq "B00004Y6O3", 'rel mbid inc urlrels release ASIN'); ok( $rel_mbid_urlrels_release->relation_list()->target_type() eq "Url", 'rel mbid inc urlrels release rellist TARGETTYPE'); foreach my $relation (@{ $rel_mbid_urlrels_release->relation_list()->relations() }) { if($relation->target() eq 'http://en.wikipedia.org/wiki/1984_%28Van_Halen_album%29') { ok( $relation->type() eq "Wikipedia", 'rel mbid inc urlrels release TYPE'); last; } } # track-level-rels my $rel_mbid_labels_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'release-events+labels' }); ok( $rel_mbid_labels_response, 'rel mbid inc labels'); my $rel_mbid_labels_release = $rel_mbid_labels_response->release(); ok( $rel_mbid_labels_release, 'rel mbid inc labels RELEASE'); ok( $rel_mbid_labels_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc labels release ID'); ok( $rel_mbid_labels_release->type() eq "Album Official", 'rel mbid inc labels release TYPE'); ok( $rel_mbid_labels_release->title() eq "1984", 'rel mbid inc labels release TITLE'); ok( $rel_mbid_labels_release->text_rep_language() eq "ENG", 'rel mbid inc labels release LANG'); ok( $rel_mbid_labels_release->text_rep_script() eq "Latn", 'rel mbid inc labels release SCRIPT'); ok( $rel_mbid_labels_release->asin() eq "B00004Y6O3", 'rel mbid inc labels release ASIN'); foreach my $event (@{ $rel_mbid_labels_release->release_event_list()->events() }) { if($event->barcode() eq '075992398527') { ok( $event->date() eq "1984-01-09", 'rel mbid inc labels release event DATE'); ok( $event->country() eq "US", 'rel mbid inc labels release event COUNTRY'); ok( $event->catalog_number() eq "9 23985-2", 'rel mbid inc labels release event CAT NUM'); ok( $event->format() eq "CD", 'rel mbid inc labels release event FORMAT'); ok( $event->label()->id() eq "c595c289-47ce-4fba-b999-b87503e8cb71", 'rel mbid inc labels release event label ID'); ok( $event->label()->name() eq "Warner Bros. Records", 'rel mbid inc labels release event label NAME'); last; } } sleep($sleep_duration); my $rel_mbid_tags_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'tags' }); ok( $rel_mbid_tags_response, 'rel mbid inc tags'); my $rel_mbid_tags_release = $rel_mbid_tags_response->release(); ok( $rel_mbid_tags_release, 'rel mbid inc tags RELEASE'); ok( $rel_mbid_tags_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc tags release ID'); ok( $rel_mbid_tags_release->type() eq "Album Official", 'rel mbid inc tags release TYPE'); ok( $rel_mbid_tags_release->title() eq "1984", 'rel mbid inc tags release TITLE'); ok( $rel_mbid_tags_release->text_rep_language() eq "ENG", 'rel mbid inc tags release LANG'); ok( $rel_mbid_tags_release->text_rep_script() eq "Latn", 'rel mbid inc tags release SCRIPT'); ok( $rel_mbid_tags_release->asin() eq "B00004Y6O3", 'rel mbid inc tags release ASIN'); foreach my $tag (@{ $rel_mbid_tags_release->tag_list()->tags() }) { ok( $tag->count() > 0, 'rel mbid inc tags tag COUNT') if($tag->text() eq "hard rock"); ok( $tag->count() > 0, 'rel mbid inc tags tag COUNT') if($tag->text() eq "rock"); ok( $tag->count() > 0, 'rel mbid inc tags tag COUNT') if($tag->text() eq "1984"); } my $rel_mbid_ratings_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'ratings' }); ok( $rel_mbid_ratings_response, 'rel mbid inc ratings'); my $rel_mbid_ratings_release = $rel_mbid_ratings_response->release(); ok( $rel_mbid_ratings_release, 'rel mbid inc ratings RELEASE'); ok( $rel_mbid_ratings_release->id() eq "ff565cd7-acf8-4dc0-9603-72d1b7ae284b", 'rel mbid inc ratings release ID'); ok( $rel_mbid_ratings_release->type() eq "Album Official", 'rel mbid inc ratings release TYPE'); ok( $rel_mbid_ratings_release->title() eq "1984", 'rel mbid inc ratings release TITLE'); ok( $rel_mbid_ratings_release->text_rep_language() eq "ENG", 'rel mbid inc ratings release LANG'); ok( $rel_mbid_ratings_release->text_rep_script() eq "Latn", 'rel mbid inc ratings release SCRIPT'); ok( $rel_mbid_ratings_release->asin() eq "B00004Y6O3", 'rel mbid inc ratings release ASIN'); ok( $rel_mbid_ratings_release->rating()->votes_count() > 1, 'rel mbid inc ratings release rating VOTE COUNT'); ok( $rel_mbid_ratings_release->rating()->value() > 3, 'rel mbid inc ratings release rating TEXT'); # isrcs done_testing(); WebService-MusicBrainz-0.93/t/Artist.t0000444000175000017500000005106211304125306017124 0ustar bfaistbfaist# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl WebService-MusicBrainz.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use strict; use Test::More; BEGIN { use_ok('WebService::MusicBrainz::Artist') }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $sleep_duration = 2; my $ws = WebService::MusicBrainz::Artist->new(); ok( $ws, 'create WebService::MusicBrainz::Artist object' ); my $wsde = WebService::MusicBrainz::Artist->new(HOST => 'de.musicbrainz.org'); my $wsde_query = $wsde->query(); ok( $wsde_query->{_baseurl} =~ m/de\.musicbrainz\.org/, 'create WebService::MusicBrainz::Artist object/altername host' ); my $mbid_response = $ws->search({ MBID => '4eca1aa0-c79f-481b-af8a-4a2d6c41aa5c' }); ok( $mbid_response, 'artist by MBID' ); my $mbid_artist = $mbid_response->artist(); ok( $mbid_artist, 'artist obj'); ok( $mbid_artist->name() eq "Miranda Lambert", 'artist name'); ok( $mbid_artist->sort_name() eq "Lambert, Miranda", 'artist sort_name'); ok( $mbid_artist->life_span_begin() eq "1983-11-10", 'artist life_span_begin'); my $name_response = $ws->search({ NAME => 'Pantera' }); ok( $name_response, 'artist by NAME' ); my $name_artist_list = $name_response->artist_list(); ok( $name_artist_list, 'artist list obj' ); ok( $name_artist_list->count() >= 3, 'artist list count' ); ok( $name_artist_list->offset() == 0, 'artist list offset' ); my $name_artist = $name_artist_list->artists()->[0]; ok( $name_artist, 'first artist' ); ok( $name_artist->id() eq "541f16f5-ad7a-428e-af89-9fa1b16d3c9c", 'first artist id' ); ok( $name_artist->name() eq "Pantera", 'first artist name' ); ok( $name_artist->sort_name() eq "Pantera", 'first artist sort-name' ); ok( $name_artist->type() eq "Group", 'first artist type' ); ok( $name_artist->score() > 90, 'first artist score' ); ok( $name_artist->life_span_begin() eq "1982", 'first artist life-span-begin' ); ok( $name_artist->life_span_end() eq "2003", 'first artist life-span-end' ); sleep($sleep_duration); my $name_limit_response = $ws->search({ NAME => 'Elvis', LIMIT => 3 }); ok( $name_limit_response, 'artist by NAME LIMIT' ); my $name_limit_artist_list = $name_limit_response->artist_list(); ok( $name_limit_artist_list, 'artist list by NAME LIMIT'); ok( $name_limit_artist_list->count() > 90, 'artist list count LIMIT'); my $artist_counter = 0; foreach my $artist_node (@{ $name_limit_artist_list->artists() }) { $artist_counter++; } ok( $artist_counter == 3, 'artist limit check'); my $name_offset_response = $ws->search({ NAME => 'Elvis', OFFSET => 10 }); ok( $name_offset_response, 'artist by NAME OFFSET' ); my $name_offset_artist_list = $name_offset_response->artist_list(); ok( $name_offset_artist_list, 'artist list OFFSET'); ok( $name_offset_artist_list->count() > 90, 'artist offset COUNT'); ok( $name_offset_artist_list->offset() == 10, 'artist offset OFFSET'); sleep($sleep_duration); my $name_limit_offset_response = $ws->search({ NAME => 'Elvis', LIMIT => 5, OFFSET => 6 }); ok( $name_limit_offset_response, 'artist by NAME LIMIT OFFSET' ); my $name_limit_offset_artist_list = $name_limit_offset_response->artist_list(); ok( $name_limit_offset_artist_list, 'artist list LIMIT OFFSET' ); ok( $name_limit_offset_artist_list->offset() == 6, 'artist limit offset OFFSET'); my $mbid_aliases_response = $ws->search({ MBID => '070d193a-845c-479f-980e-bef15710653e', INC => 'aliases' }); ok( $mbid_aliases_response, 'artist by MBID ALIASES' ); my $mbid_aliases_artist = $mbid_aliases_response->artist(); ok( $mbid_aliases_artist, 'artist aliases'); ok( $mbid_aliases_artist->type() eq "Person", 'artist aliases TYPE'); ok( $mbid_aliases_artist->name() eq "Prince", 'artist aliases NAME'); ok( $mbid_aliases_artist->sort_name() eq "Prince", 'artist aliases SORT NAME'); ok( $mbid_aliases_artist->life_span_begin() eq "1958-06-07", 'artist aliases LIFE SPAN BEGIN'); my $mbid_aliases_alias_list = $mbid_aliases_artist->alias_list(); ok( $mbid_aliases_alias_list, 'artist aliases ALIAS LIST'); ok( scalar(@{ $mbid_aliases_alias_list->aliases() }) > 2, 'artist aliases ALIAS COUNT'); sleep($sleep_duration); my $mbid_release_groups_response = $ws->search({ MBID => '4dca4bb2-23ba-4103-97e6-5810311db33a', INC => 'release-groups sa-Album' }); ok( $mbid_release_groups_response, 'artist by MBID RELEASE-GROUPS' ); my $mbid_rg_artist = $mbid_release_groups_response->artist(); ok( $mbid_rg_artist, 'artist release-groups'); my $mbid_rg_release_list = $mbid_rg_artist->release_list(); ok( $mbid_rg_release_list,'artist release-groups RELEASE LIST'); my $mbid_rg_release_group_list = $mbid_rg_artist->release_group_list(); ok( $mbid_rg_release_group_list, 'artist release-groups RELEASE GROUP LIST'); ok( scalar(@{ $mbid_rg_release_group_list->release_groups() }) > 1, 'artist release-groups RELEASE GROUPS'); my $mbid_artist_rels_response = $ws->search({ MBID => 'ae1b47d5-5128-431c-9d30-e08fd90e0767', INC => 'artist-rels' }); ok( $mbid_artist_rels_response, 'artist by MBID ARTIST-RELS' ); my $mbid_artist_rels_artist = $mbid_artist_rels_response->artist(); ok( $mbid_artist_rels_artist, 'artist artist-rels ARTIST'); ok( $mbid_artist_rels_artist->type() eq "Group", 'artist artist-rels GROUP'); ok( $mbid_artist_rels_artist->name() eq "Coheed and Cambria", 'artist artist-rels NAME'); ok( $mbid_artist_rels_artist->sort_name() eq "Coheed and Cambria", 'artist artist-rels SORT NAME'); my $mbid_artist_rels_list = $mbid_artist_rels_artist->relation_list(); ok( $mbid_artist_rels_list, 'artist artist-rels RELATION LIST'); ok( $mbid_artist_rels_list->target_type() eq "Artist",'artist artist-rels relation-list TARGET TYPE'); foreach my $relation (@{ $mbid_artist_rels_list->relations() }) { if($relation->target() eq "56c0c0ec-5973-4ce8-9fd8-ba7b46ce0a9e") { ok( $relation->type() eq "MemberOfBand", 'artist artist-rels relation TYPE'); ok( $relation->direction() eq "backward", 'artist artist-rels relation DIRECTION'); ok( $relation->begin() eq "1995", 'artist artist-rels relation BEGIN'); my $ar = $relation->artist(); ok( $ar, 'artist artist-rels relation ARTIST'); ok( $ar->id() eq "56c0c0ec-5973-4ce8-9fd8-ba7b46ce0a9e", 'artist artist-rels relation artist ID'); ok( $ar->type() eq "Person", 'artist artist-rels relation artist PERSON'); ok( $ar->name() eq "Claudio Sanchez", 'artist artist-rels relation artist NAME'); ok( $ar->sort_name() eq "Sanchez, Claudio", 'artist artist-rels relation artist SORT NAME'); ok( $ar->life_span_begin() eq "1978-03-12", 'artist artist-rels relation artist LIFE SPAN BEGIN'); last; } } sleep($sleep_duration); my $mbid_label_rels_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'label-rels+sa-Official' }); ok( $mbid_label_rels_response, 'artist by MBID LABEL-RELS' ); my $mbid_label_rels_artist = $mbid_label_rels_response->artist(); ok( $mbid_label_rels_artist,'artist label rels ARTIST'); my $mbid_label_rels_release_list = $mbid_label_rels_artist->release_list(); ok( $mbid_label_rels_release_list, 'artist label_rels RELEASE LIST'); foreach my $release (@{ $mbid_label_rels_release_list->releases() }) { if($release->id() eq "940d6fba-3603-4ac2-8f5d-ea0a11e51765") { ok($release->type() eq "Album Official",'artist label rels release TYPE'); my $relation_list = $release->relation_list(); ok($relation_list->target_type() eq "Label", 'artist label-rels release relation_list TYPE'); foreach my $relation (@{ $relation_list->relations() }) { if($relation->target() eq "82275f26-c259-4a3e-a476-91277f1d0c3d") { ok($relation->type() eq "Publishing", 'artist label-rels relation TYPE'); ok($relation->label(), 'artist label-res relation LABEL'); ok($relation->label()->name() eq "Creeping Death Music", 'artist label-rels label NAME'); ok($relation->label()->sort_name() eq "Creeping Death Music", 'artist label-rels label SORT NAME'); ok($relation->label()->country() eq "US", 'artist label-rels label COUNTRY'); last; } } last; } } my $mbid_release_rels_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'release-rels' }); ok( $mbid_release_rels_response, 'artist by MBID RELEASE-RELS' ); my $mbid_release_rels_artist = $mbid_release_rels_response->artist(); ok( $mbid_release_rels_artist, 'artist release rels ARTIST'); ok( $mbid_release_rels_artist->name() eq "Metallica", 'artist release rels artist NAME'); ok( $mbid_release_rels_artist->sort_name() eq "Metallica", 'artist release rels artist SORT NAME'); ok( $mbid_release_rels_artist->life_span_begin() eq "1981-10", 'artist release rels artist BEGIN'); my $mbid_release_rels_list = $mbid_release_rels_artist->relation_list(); ok( $mbid_release_rels_list, 'artist release rels RELATION LIST'); ok( $mbid_release_rels_list->target_type() eq "Release", 'artist release rels RELATION LIST'); ok( scalar(@{ $mbid_release_rels_list->relations() }) > 0, 'artist release rels RELEASES'); foreach my $relation (@{ $mbid_release_rels_list->relations() }) { if($relation->target() eq "552c4163-397e-4ae3-8da5-8f551ebbdbc1") { ok( $relation->type() eq "Tribute", 'artist release rels relation TYPE'); ok( $relation->release()->type() eq "EP Official", 'artist release rels relation release TYPE'); ok( $relation->release()->title() eq "A Tribute to Metallica", 'artist release rels relation release TITLE'); ok( $relation->release()->text_rep_language() eq "ENG", 'artist release rels relation release LANG'); ok( $relation->release()->text_rep_script() eq "Latn", 'artist release rels relation release SCRIPT'); last; } } sleep($sleep_duration); my $mbid_track_rels_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'track-rels' }); ok( $mbid_track_rels_response, 'artist by MBID TRACK-RELS' ); my $mbid_track_rels_artist = $mbid_track_rels_response->artist(); ok( $mbid_track_rels_artist, 'artist track rels ARTIST' ); ok( $mbid_track_rels_artist->name() eq "Metallica", 'artist track rels artist NAME'); ok( $mbid_track_rels_artist->sort_name() eq "Metallica", 'artist track rels artist SORT NAME'); my $mbid_track_rels_list = $mbid_track_rels_artist->relation_list(); ok( $mbid_track_rels_list, 'artist track rels artist RELATION LIST' ); ok( $mbid_track_rels_list->target_type() eq "Track", 'artist track rels artist relation list TYPE'); ok( scalar(@{ $mbid_track_rels_list->relations() }) > 0, 'artist track rels artist relation list RELATIONS'); foreach my $track_rel (@{ $mbid_track_rels_list->relations() }) { if($track_rel->target() eq "f415a50d-4594-4d39-b84d-57afd433ef6d") { ok( $track_rel->type() eq "Performer", 'artist track rels relation TYPE'); ok( $track_rel->track()->title() eq "Halloween (feat. Metallica)", 'artist track rels relation track TITLE'); ok( $track_rel->track()->duration() eq "174200", 'artist track rels relation track DURATION'); last; } } my $mbid_url_rels_response = $ws->search({ MBID => 'ae1b47d5-5128-431c-9d30-e08fd90e0767', INC => 'url-rels' }); ok( $mbid_url_rels_response, 'artist by MBID URL-RELS' ); my $mbid_url_rels_artist = $mbid_url_rels_response->artist(); ok( $mbid_url_rels_artist, 'artist url rels ARTIST'); ok( $mbid_url_rels_artist->name() eq "Coheed and Cambria", 'artist url rels artist NAME'); ok( $mbid_url_rels_artist->sort_name() eq "Coheed and Cambria", 'artist url rels artist SORT NAME'); my $mbid_url_rels_list = $mbid_url_rels_artist->relation_list(); ok( $mbid_url_rels_list, 'artist url rels artist RELATION LIST'); ok( $mbid_url_rels_list->target_type() eq "Url", 'artist url rels artist relation list TYPE'); foreach my $url_rel (@{ $mbid_url_rels_list->relations() }) { if($url_rel->type() eq "Wikipedia") { ok($url_rel->target() eq "http://en.wikipedia.org/wiki/Coheed_and_Cambria", 'artist url rels relation URL TYPE'); last; } } sleep($sleep_duration); my $mbid_tags_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'tags' }); ok( $mbid_tags_response, 'artist by MBID TAGS' ); my $mbid_tags_artist = $mbid_tags_response->artist(); ok( $mbid_tags_artist, 'artist tags ARTIST'); ok( $mbid_tags_artist->name() eq "Metallica", 'artist tags artist NAME'); ok( $mbid_tags_artist->sort_name() eq "Metallica", 'artist tags artist SORT NAME'); my $mbid_tags_tag_list = $mbid_tags_artist->tag_list(); ok( $mbid_tags_tag_list, 'artist tags artist TAGLIST'); foreach my $tag (@{ $mbid_tags_tag_list->tags() }) { if($tag->text() eq "heavy metal") { ok($tag->count() > 2, 'artist tags tag COUNT2'); } } my $mbid_ratings_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'ratings' }); ok( $mbid_ratings_response, 'artist by MBID RATINGS' ); my $mbid_ratings_artist = $mbid_ratings_response->artist(); ok( $mbid_ratings_artist, 'artist ratings ARTIST'); ok( $mbid_ratings_artist->name() eq "Metallica", 'artist ratings artist NAME'); ok( $mbid_ratings_artist->sort_name() eq "Metallica", 'artist ratings artist SORT NAME'); my $mbid_ratings_rating = $mbid_ratings_artist->rating(); ok( $mbid_ratings_rating, 'artist ratings RATING'); ok( $mbid_ratings_rating->votes_count() > 20, 'artist ratings rating VOTE COUNT'); ok( $mbid_ratings_rating->value() > 3 , 'artist ratings rating VALUE'); # TODO: requires auth/credentials # my $mbid_user_tags_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'user-tags' }); # ok( $mbid_user_tags_response, 'artist by MBID USERs-TAGS' ); # # my $mbid_user_ratings_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'user-ratings' }); # ok( $mbid_user_ratings_response, 'artist by MBID USER-RATINGS' ); sleep($sleep_duration); my $mbid_counts_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'counts+sa-Official' }); ok( $mbid_counts_response, 'artist by MBID COUNTS' ); my $mbid_counts_artist = $mbid_counts_response->artist(); ok( $mbid_counts_artist, 'artist counts ARTIST'); my $mbid_counts_rel_list = $mbid_counts_artist->release_list(); ok( $mbid_counts_rel_list, 'artist counts artist RELEASE LIST'); foreach my $release (@{ $mbid_counts_rel_list->releases() }) { if($release->id() eq "fed37cfc-2a6d-4569-9ac0-501a7c7598eb") { ok( $release->type() eq "Album Official", 'artist counts release TYPE'); ok( $release->title() eq "Master of Puppets", 'artist counts release TITLE'); ok( $release->text_rep_language() eq "ENG", 'artist counts release TEXT LANG'); ok( $release->text_rep_script() eq "Latn", 'artist counts release TEXT SCRIPT'); ok( $release->asin() eq "B000025ZVE", 'artist counts release ASIN'); ok( $release->disc_list()->count() > 10, 'artist counts release DISC LIST COUNT'); ok( $release->track_list()->count() > 5, 'artist counts release TRACK LIST COUNT'); ok( $release->release_event_list()->count() > 10, 'artist counts release event list COUNT'); last; } } my $mbid_rel_events_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'release-events+sa-Official' }); ok( $mbid_rel_events_response, 'artist by MBID RELEASE-EVENTS' ); my $mbid_rel_events_artist = $mbid_rel_events_response->artist(); ok( $mbid_rel_events_artist, 'artist rel events ARTIST'); ok( $mbid_rel_events_artist->name() eq "Metallica", 'artist rel events artist NAME'); ok( $mbid_rel_events_artist->sort_name() eq "Metallica", 'artist rel events artist SORT NAME'); foreach my $release (@{ $mbid_rel_events_artist->release_list()->releases() }) { if($release->id() eq "a89e1d92-5381-4dab-ba51-733137d0e431") { ok( $release->type() eq "Album Official", 'artist rel events release TYPE'); ok( $release->title() eq "Kill 'em All", 'artist rel events release TITLE'); ok( $release->text_rep_language() eq "ENG", 'artist rel events release LANG'); ok( $release->text_rep_script() eq "Latn", 'artist rel events release SCRIPT'); foreach my $event (@{ $release->release_event_list()->events() }) { if($event->barcode() && $event->barcode() eq "075596076623") { ok( $event->date() eq "1988-01-15", 'artist rel events release events DATE'); ok( $event->country() eq "US", 'artist rel events release events COUNTRY'); ok( $event->catalog_number() eq "CD 60766", 'artist rel events release events CATALOG NUMBER'); ok( $event->format() eq "CD", 'artist rel events release events FORMAT'); last; } } last; } } sleep($sleep_duration); my $mbid_discs_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'discs+sa-Official' }); ok( $mbid_discs_response, 'artist by MBID DISCS' ); my $mbid_discs_artist = $mbid_discs_response->artist(); ok( $mbid_discs_artist, 'artist discs ARTIST'); ok( $mbid_discs_artist->name() eq "Metallica", 'artist discs artist NAME'); ok( $mbid_discs_artist->sort_name() eq "Metallica", 'artist discs artist SORT NAME'); foreach my $release (@{ $mbid_discs_artist->release_list()->releases() }) { if($release->id() eq "456efd39-f0dc-4b4d-87c7-82bbc562d8f3") { ok( $release->type() eq "Album Official", 'artist discs release TYPE'); ok( $release->title() eq "Ride the Lightning", 'artist discs release TITLE'); ok( $release->text_rep_language() eq "ENG", 'artist discs release LANG'); ok( $release->text_rep_script() eq "Latn", 'artist discs release SCRIPT'); ok( $release->asin() eq "B000002H2H", 'artist discs release ASIN'); foreach my $disc (@{ $release->disc_list()->discs() }) { if($disc->id() eq "UhuTnSAqRRgWbuC0zf1rvAzFX9M-") { ok( $disc->sectors() eq "213595", 'artist discs disc-list disc SECTORS'); last; } } last; } } my $mbid_labels_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'labels+release-events+sa-Official' }); ok( $mbid_labels_response, 'artist by MBID LABELS' ); my $mbid_labels_artist = $mbid_labels_response->artist(); ok( $mbid_labels_artist, 'artist labels ARTIST'); ok( $mbid_labels_artist->name() eq "Metallica", 'artist labels artist NAME'); ok( $mbid_labels_artist->sort_name() eq "Metallica", 'artist labels artist SORT NAME'); foreach my $release (@{ $mbid_labels_artist->release_list()->releases() }) { if($release->id() eq "456efd39-f0dc-4b4d-87c7-82bbc562d8f3") { ok( $release->type() eq "Album Official", 'artist labels release TYPE'); ok( $release->title() eq "Ride the Lightning", 'artist labels release TITLE'); ok( $release->text_rep_language() eq "ENG", 'artist labels release LANG'); ok( $release->text_rep_script() eq "Latn", 'artist labels release SCRIPT'); ok( $release->asin() eq "B000002H2H", 'artist labels release ASIN'); foreach my $event (@{ $release->release_event_list()->events() }) { if($event->barcode() eq "075596039628") { ok( $event->date() eq "1987", 'artist labels release event DATE'); ok( $event->country() eq "US", 'artist labels release event COUNTRY'); ok( $event->format() eq "CD", 'artist labels release event FORMAT'); ok( $event->catalog_number() eq "9 60396-2", 'artist labels release event CATALOG'); ok( $event->label()->id() eq "873f9f75-af68-4872-98e2-431058e4c9a9", 'artist labels release event label ID'); ok( $event->label()->name() eq "Elektra", 'artist labels release event label NAME'); last; } } last; } } sleep($sleep_duration); my $q1_response = $ws->search({ QUERY => 'begin:1990 AND type:group'}); ok($q1_response, 'artist query begin type'); foreach my $artist (@{ $q1_response->artist_list()->artists() }) { if($artist->id() eq "e9571c17-817f-4d34-ae3f-0c7a96f822c1") { ok($artist->type() eq "Group", 'artist query begin type TYPE'); ok($artist->name() eq "Temple of the Dog", 'artist query begin type NAME'); ok($artist->sort_name() eq "Temple of the Dog", 'artist query begin type SORT NAME'); ok($artist->life_span_begin() eq "1990", 'artist query begin type LIFE SPAN BEGIN'); ok($artist->life_span_end() eq "1991", 'artist query begin type LIFE SPAN END'); last; } } my $search_name_utf8 = $ws->search({ NAME => 'ザ・リリーズ' }); ok( $search_name_utf8, 'get NAME search response object when NAME is UTF-8 encoded' ); done_testing(); WebService-MusicBrainz-0.93/Changes0000444000175000017500000000734511304125306016526 0ustar bfaistbfaistRevision history for Perl extension WebService::MusicBrainz. 0.01 Mon Apr 24 23:43:14 2006 - original version; created by h2xs 1.23 with options -AXn WebService::MusicBrainz 0.02 Thu Apr 27 2006 - Improved documentation - Removed debug print statement - Added factory object WebService::MusicBrainz - Improved test cases, added Factory.t test script - include META.yml which was missing originally - Remove .swp file accidentally left in distribution 0.03 Wed Sep 27 2006 - RT Bug 21511 fix (Thomas Adamcik) - RT Bug 21755 fix (Powder) 0.04 Wed Nov 15 2006 - Added feature for alternate mirrored host - Added more response objects to more closly match schema - Much closer to spec compliant (Schema: musicbrainz_mmd-1.0rc5.rng) 0.05 Thu Nov 16 2006 - Some test were failing so I corrected those and added a few more 0.06 Mon Nov 26 2006 - Incomplete MANIFEST file causing failures 0.07 Tue Feb 13 2007 - Failing test due to data change, test corrected (HairMetalAddict) 0.08 Web Apr 25 2007 - Another test was failing due to data change. 0.09 Sun May 13 2007 - Switched XML parsing from XML::Twig to XML::LibXML - Converted packaging to Module::Build with ExtUtils::MakeMaker compatibility - Fixed failing test in Release.t 0.10 Mon May 28 2007 - RT Bug 27287 fix (Ron Kuper) - More tests to check offsets are usable - Set user agent string 0.11 Mon Jul 9 2007 - LWP::UserAgent proxy enabled - Michael Ablassmeier - Fix bug with Response.pm - Michael Ablassmeier - Fixed failing tests in Release.t 0.12 Thu Nov 15 2007 - More compliant with 1.2 MMD Schema - Added "label" support and test cases - Fixed test case count in Release.t 0.13 Sun Dec 2 2007 - Fixed failing tests in Release.t 0.14 Mon Dec 3 2007 - Fixed test count in Release.t 0.15 Mon Dec 3 2007 - Added "URI" to required modules in Build.PL 0.16 Wed Dec 5 2007 - Updated t/Release.t 0.17 Sat Mar 2 2008 - Added URI escaping to URL (Edward Allen) - Added support for label, catno, and barcode in realease events - Changed how first object returned from collection (was shift, now ->[0]) - Added delays in test scripts to help not exceed webservice request threshold - Updated test cases 0.18 Wed May 14th 2008 - Update test in Release.t (Stefan) 0.19 Tue Oct 21st 2008 - RT bug 39945 - Chris Key 0.20 Mon Jan 5th 2009 - RT Bug 40597 - Slaven - Updated Build.PL perl version - RT Bug 42169 - pbryan - Fixed PUID object creation - Added test cases for PUID objects to Track.t 0.21 Mon Feb 2nd 2009 - RT Bug 42482 - orivej - Changed URI creation for multiple INC params - RT Bug 42534 - Chris Key - Applied patch to fix tag and alias parsing - fixed failing test in Artist.t - Added documentation about multiple INC params - Added test case to Artist.t for multiple INC params 0.22 Sat Apr 25th 2009 - RT Bug 44065 - Chris Key - Added new API "relation_lists" to Release response object - API method "relation_list" returns first relation list object - New API method "relation_lists" returns array ref with all relation lists - Added more tests to Release.t 0.90 Tue Oct 13th 2009 - RT Bug 48661 - Chris Key - Integrated supplied patch - Added ISRC support - RT Bug 50054 - Peter Oliver - Integrated supplied patch - Fixed UTF8 support - Made compliant with MMD 1.4 schema - Rewrote test cases (still more to do) - Added support for direct Lucene queries (suggest: Dave Hodgkinson) 0.91 Mon Oct 19th 2009 - RT Bug 50581 - Andreas Koenig - Added prereq for Test::More 0.88 0.92 Sat Nov 1st 2009 - Fixed failing test in Release.t 0.93 Fri Nov 27th 2009 - Release event lists are now sorted from earliest to the most recent WebService-MusicBrainz-0.93/META.yml0000444000175000017500000001154011304125306016474 0ustar bfaistbfaist--- name: WebService-MusicBrainz version: 0.93 author: - 'Bob Faist ' abstract: Web service API to MusicBrainz database license: perl resources: license: http://dev.perl.org/licenses/ repository: git://github.com/bfaist/webservice-musicbrainz.git requires: Class::Accessor: 0.30 LWP::UserAgent: 2.0 Test::More: 0.88 URI: 1.35 XML::LibXML: 1.63 perl: 5.7.0 provides: WebService::MusicBrainz: file: lib/WebService/MusicBrainz.pm version: 0.93 WebService::MusicBrainz::Artist: file: lib/WebService/MusicBrainz/Artist.pm version: 0.93 WebService::MusicBrainz::Label: file: lib/WebService/MusicBrainz/Label.pm version: 0.93 WebService::MusicBrainz::Query: file: lib/WebService/MusicBrainz/Query.pm version: 0.93 WebService::MusicBrainz::Release: file: lib/WebService/MusicBrainz/Release.pm version: 0.93 WebService::MusicBrainz::ReleaseGroup: file: lib/WebService/MusicBrainz/ReleaseGroup.pm version: 0.93 WebService::MusicBrainz::Response: file: lib/WebService/MusicBrainz/Response.pm version: 0.93 WebService::MusicBrainz::Response::Alias: file: lib/WebService/MusicBrainz/Response/Alias.pm version: 0.93 WebService::MusicBrainz::Response::AliasList: file: lib/WebService/MusicBrainz/Response/AliasList.pm version: 0.93 WebService::MusicBrainz::Response::Artist: file: lib/WebService/MusicBrainz/Response/Artist.pm version: 0.93 WebService::MusicBrainz::Response::ArtistList: file: lib/WebService/MusicBrainz/Response/ArtistList.pm version: 0.93 WebService::MusicBrainz::Response::Disc: file: lib/WebService/MusicBrainz/Response/Disc.pm version: 0.93 WebService::MusicBrainz::Response::DiscList: file: lib/WebService/MusicBrainz/Response/DiscList.pm version: 0.93 WebService::MusicBrainz::Response::ISRC: file: lib/WebService/MusicBrainz/Response/ISRC.pm version: 0.93 WebService::MusicBrainz::Response::ISRCList: file: lib/WebService/MusicBrainz/Response/ISRCList.pm version: 0.93 WebService::MusicBrainz::Response::Label: file: lib/WebService/MusicBrainz/Response/Label.pm version: 0.93 WebService::MusicBrainz::Response::LabelList: file: lib/WebService/MusicBrainz/Response/LabelList.pm version: 0.93 WebService::MusicBrainz::Response::Metadata: file: lib/WebService/MusicBrainz/Response/Metadata.pm version: 0.93 WebService::MusicBrainz::Response::Puid: file: lib/WebService/MusicBrainz/Response/Puid.pm version: 0.93 WebService::MusicBrainz::Response::PuidList: file: lib/WebService/MusicBrainz/Response/PuidList.pm version: 0.93 WebService::MusicBrainz::Response::Rating: file: lib/WebService/MusicBrainz/Response/Rating.pm version: 0.93 WebService::MusicBrainz::Response::Relation: file: lib/WebService/MusicBrainz/Response/Relation.pm version: 0.93 WebService::MusicBrainz::Response::RelationList: file: lib/WebService/MusicBrainz/Response/RelationList.pm version: 0.93 WebService::MusicBrainz::Response::Release: file: lib/WebService/MusicBrainz/Response/Release.pm version: 0.93 WebService::MusicBrainz::Response::ReleaseEvent: file: lib/WebService/MusicBrainz/Response/ReleaseEvent.pm version: 0.93 WebService::MusicBrainz::Response::ReleaseEventList: file: lib/WebService/MusicBrainz/Response/ReleaseEventList.pm version: 0.93 WebService::MusicBrainz::Response::ReleaseGroup: file: lib/WebService/MusicBrainz/Response/ReleaseGroup.pm version: 0.93 WebService::MusicBrainz::Response::ReleaseGroupList: file: lib/WebService/MusicBrainz/Response/ReleaseGroupList.pm version: 0.93 WebService::MusicBrainz::Response::ReleaseList: file: lib/WebService/MusicBrainz/Response/ReleaseList.pm version: 0.93 WebService::MusicBrainz::Response::Tag: file: lib/WebService/MusicBrainz/Response/Tag.pm version: 0.93 WebService::MusicBrainz::Response::TagList: file: lib/WebService/MusicBrainz/Response/TagList.pm version: 0.93 WebService::MusicBrainz::Response::Track: file: lib/WebService/MusicBrainz/Response/Track.pm version: 0.93 WebService::MusicBrainz::Response::TrackList: file: lib/WebService/MusicBrainz/Response/TrackList.pm version: 0.93 WebService::MusicBrainz::Response::UserRating: file: lib/WebService/MusicBrainz/Response/UserRating.pm version: 0.93 WebService::MusicBrainz::Response::UserTag: file: lib/WebService/MusicBrainz/Response/UserTag.pm version: 0.93 WebService::MusicBrainz::Response::UserTagList: file: lib/WebService/MusicBrainz/Response/UserTagList.pm version: 0.93 WebService::MusicBrainz::Track: file: lib/WebService/MusicBrainz/Track.pm version: 0.93 generated_by: Module::Build version 0.280801 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.2.html version: 1.2 keywords: - musicbrainz - webservice WebService-MusicBrainz-0.93/MANIFEST0000444000175000017500000000344611304125306016362 0ustar bfaistbfaistBuild.PL Changes lib/WebService/MusicBrainz.pm lib/WebService/MusicBrainz/Artist.pm lib/WebService/MusicBrainz/Label.pm lib/WebService/MusicBrainz/Query.pm lib/WebService/MusicBrainz/Release.pm lib/WebService/MusicBrainz/ReleaseGroup.pm lib/WebService/MusicBrainz/Response.pm lib/WebService/MusicBrainz/Response/Alias.pm lib/WebService/MusicBrainz/Response/AliasList.pm lib/WebService/MusicBrainz/Response/Artist.pm lib/WebService/MusicBrainz/Response/ArtistList.pm lib/WebService/MusicBrainz/Response/Disc.pm lib/WebService/MusicBrainz/Response/DiscList.pm lib/WebService/MusicBrainz/Response/ISRC.pm lib/WebService/MusicBrainz/Response/ISRCList.pm lib/WebService/MusicBrainz/Response/Label.pm lib/WebService/MusicBrainz/Response/LabelList.pm lib/WebService/MusicBrainz/Response/Metadata.pm lib/WebService/MusicBrainz/Response/Puid.pm lib/WebService/MusicBrainz/Response/PuidList.pm lib/WebService/MusicBrainz/Response/Rating.pm lib/WebService/MusicBrainz/Response/Relation.pm lib/WebService/MusicBrainz/Response/RelationList.pm lib/WebService/MusicBrainz/Response/Release.pm lib/WebService/MusicBrainz/Response/ReleaseEvent.pm lib/WebService/MusicBrainz/Response/ReleaseEventList.pm lib/WebService/MusicBrainz/Response/ReleaseGroup.pm lib/WebService/MusicBrainz/Response/ReleaseGroupList.pm lib/WebService/MusicBrainz/Response/ReleaseList.pm lib/WebService/MusicBrainz/Response/Tag.pm lib/WebService/MusicBrainz/Response/TagList.pm lib/WebService/MusicBrainz/Response/Track.pm lib/WebService/MusicBrainz/Response/TrackList.pm lib/WebService/MusicBrainz/Response/UserRating.pm lib/WebService/MusicBrainz/Response/UserTag.pm lib/WebService/MusicBrainz/Response/UserTagList.pm lib/WebService/MusicBrainz/Track.pm Makefile.PL MANIFEST This list of files META.yml README t/Artist.t t/Label.t t/Release.t t/ReleaseGroup.t t/Track.t WebService-MusicBrainz-0.93/Build.PL0000444000175000017500000000150611304125306016520 0ustar bfaistbfaistuse Module::Build; my $build = Module::Build->new ( module_name => 'WebService::MusicBrainz', dist_abstract => 'Web service API to MusicBrainz database', license => 'perl', requires => { 'perl' => '5.7.0', 'XML::LibXML' => '1.63', 'LWP::UserAgent' => '2.0', 'Class::Accessor' => '0.30', 'Test::More' => '0.88', 'URI' => '1.35', }, create_makefile_pl => 'traditional', dist_author => 'Bob Faist ', dist_version => '0.93', meta_merge => { resources => { repository => 'git://github.com/bfaist/webservice-musicbrainz.git' }, keywords => [ qw/musicbrainz webservice/ ] }, ); $build->create_build_script; WebService-MusicBrainz-0.93/README0000444000175000017500000000200211304125306016074 0ustar bfaistbfaistWebService-MusicBrainz =================================== This module will search the MusicBrainz database through their web service and return objects with the found data. INSTALLATION To install this module, using the ExtUtils::MakeMaker method: perl Makefile.PL make make test make install To install this module using the Module::Build method: perl Build.PL ./Build ./Build test ./Build install DEPENDENCIES This module requires these other modules and libraries: XML::LibXML LWP::UserAgent Class::Accessor URI Test::More NOTE I have seen the tests fail if the musicbrainz database server is overloaded. If this is happening, I would suggest installing during a non-peak time of the day. COPYRIGHT AND LICENCE Copyright (C) 2007-2009 by Bob Faist ( bob.faist at gmail.com ) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. WebService-MusicBrainz-0.93/lib/0000755000175000017500000000000011304125306015772 5ustar bfaistbfaistWebService-MusicBrainz-0.93/lib/WebService/0000755000175000017500000000000011304125306020030 5ustar bfaistbfaistWebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/0000755000175000017500000000000011304125306022256 5ustar bfaistbfaistWebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/ReleaseGroup.pm0000444000175000017500000000722611304125306025216 0ustar bfaistbfaistpackage WebService::MusicBrainz::ReleaseGroup; use strict; use WebService::MusicBrainz::Query; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::ReleaseGroup =head1 SYNOPSIS use WebService::MusicBrainz::ReleaseGroup; my $ws = WebService::MusicBrainz::ReleaseGroup->new(); my $response = $ws->search({ TITLE => 'ok computer' }); my $release = $response->release(); # grab first one in the list print $release->title(), " (", $release->type(), ") - ", $release->artist()->name(), "\n"; # OUTPUT: OK Computer (Album Official) - Radiohead =head1 DESCRIPTION =head1 METHODS =head2 new() This method is the constructor and it will call for initialization. =cut sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_init(@_); return $self; } sub _init { my $self = shift; my $q = WebService::MusicBrainz::Query->new(@_); $q->set_url_params(qw/mbid title artist artistid releasetypes limit offset query/); $q->set_inc_params(qw/artist releases/); $self->{_query} = $q; } =head2 query() This method will return the cached query object; =cut sub query { my $self = shift; return $self->{_query}; } =head2 search() This method is used to search the MusicBrainz database using their web service schema. The only argument is a hashref to define the search parameters. my $ws = WebService::MusicBrainz::Release->new(); my $response = $ws->search({ TITLE => 'Highway to Hell' }); my $response = $ws->search({ ARTIST => 'sleater kinney' }); my $response = $ws->search({ ARTIST => 'beatles', OFFSET => 4 }); my $response = $ws->search({ ARTISTID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab' }); my $response = $ws->search({ DISCID => 'XgrrQ8Npf9Uz_trPIFMrSz6Mk6Q-' }); my $response = $ws->search({ RELEASETYPES => 'Official', MBID => 'a89e1d92-5381-4dab-ba51-733137d0e431' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'counts' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'release-events' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'discs' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'tracks' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'release-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'track-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'url-rels' }); Multiple INC params can be delimited by whitespace, commas, or + characters. my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist url-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist,url-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist+url-rels' }); =cut sub search { my $self = shift; my $params = shift; my $response = $self->query()->get('releasegroup', $params); return $response; } =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2007 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Release.pm0000444000175000017500000001444211304125306024177 0ustar bfaistbfaistpackage WebService::MusicBrainz::Release; use strict; use WebService::MusicBrainz::Query; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Release =head1 SYNOPSIS use WebService::MusicBrainz::Release; my $ws = WebService::MusicBrainz::Release->new(); my $response = $ws->search({ TITLE => 'ok computer' }); my $release = $response->release(); # grab first one in the list print $release->title(), " (", $release->type(), ") - ", $release->artist()->name(), "\n"; # OUTPUT: OK Computer (Album Official) - Radiohead =head1 DESCRIPTION =head1 METHODS =head2 new() This method is the constructor and it will call for initialization. =cut sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_init(@_); return $self; } sub _init { my $self = shift; my $q = WebService::MusicBrainz::Query->new(@_); $q->set_url_params(qw/mbid title discid artist artistid releasetypes count date asin lang script cdstubs limit offset query/); $q->set_inc_params(qw/artist counts release-events discs tracks release-groups artist-rels label-rels release-rels track-rels url-rels track-level-rels labels tags ratings user-tags user-ratings isrcs/); $self->{_query} = $q; } =head2 query() This method will return the cached query object; =cut sub query { my $self = shift; return $self->{_query}; } =head2 search() This method is used to search the MusicBrainz database using their web service schema. The only argument is a hashref to define the search parameters. my $ws = WebService::MusicBrainz::Release->new(); my $response = $ws->search({ TITLE => 'Highway to Hell' }); my $response = $ws->search({ ARTIST => 'sleater kinney' }); my $response = $ws->search({ ARTIST => 'beatles', OFFSET => 4 }); my $response = $ws->search({ ARTISTID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab' }); my $response = $ws->search({ DISCID => 'XgrrQ8Npf9Uz_trPIFMrSz6Mk6Q-' }); my $response = $ws->search({ RELEASETYPES => 'Official', MBID => 'a89e1d92-5381-4dab-ba51-733137d0e431' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'counts' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'release-events' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'discs' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'tracks' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'release-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'track-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'url-rels' }); Multiple INC params can be delimited by whitespace, commas, or + characters. my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist url-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist,url-rels' }); my $response = $ws->search({ MBID => 'fed37cfc-2a6d-4569-9ac0-501a7c7598eb', INC => 'artist+url-rels' }); =head3 Find a release by title my $rel_title = $ws->search({ TITLE => 'Van Halen' }); =head3 Find a release by disc id my $rel_discid = $ws->search({ DISCID => 'Qb6ACLJhzNM46cXKVZSh3qMOv6A-' }); =head3 Find a release by artist name my $rel_artist_response = $ws->search({ ARTIST => 'Van Halen' }); =head3 Find a release by artist MBID my $rel_artistid_response = $ws->search({ ARTISTID => 'b665b768-0d83-4363-950c-31ed39317c15' }); =head3 Find a release by artist name and release type my $rel_reltypes_response = $ws->search({ ARTIST => 'Van Halen', RELEASETYPES => 'Bootleg' }); =head3 Find a release by artist name and count my $rel_count_response = $ws->search({ ARTIST => 'Van Halen', COUNT => 10 }); =head3 Find a release by artist name and release date my $rel_date_response = $ws->search({ ARTIST => 'Van Halen', DATE => '1980' }); =head3 Find a release by artist name and limit my $rel_limit_response = $ws->search({ ARTIST => 'Van Halen', LIMIT => "40" }); =head3 Find a release by MBID and include counts my $rel_mbid_counts_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'counts' }); =head3 Find a release by MBID and include release events my $rel_mbid_events_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'release-events' }); =head3 Find a release by MBID and include discs my $rel_mbid_discs_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'discs' }); =head3 Find a release by MBID and include tracks my $rel_mbid_tracks_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'tracks' }); =head3 Find a release by MBID and include release groups my $rel_mbid_relgroups_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'release-groups' }); =head3 Find a release by MBID and include artist relations my $rel_mbid_artistrels_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'artist-rels' }); =head3 Find a release by MBID and include URL relations my $rel_mbid_urlrels_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'url-rels' }); =head3 Find a release by MBID and include tags my $rel_mbid_tags_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'tags' }); =head3 Find a release by MBID and include ratings my $rel_mbid_ratings_response = $ws->search({ MBID => 'ff565cd7-acf8-4dc0-9603-72d1b7ae284b', INC => 'ratings' }); =cut sub search { my $self = shift; my $params = shift; my $response = $self->query()->get('release', $params); return $response; } =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2007 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Query.pm0000444000175000017500000001031611304125306023720 0ustar bfaistbfaistpackage WebService::MusicBrainz::Query; use strict; use LWP::UserAgent; use URI; use URI::Escape; use WebService::MusicBrainz::Response; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Query =head1 SYNOPSIS =head1 ABSTRACT WebService::MusicBrainz - Interface with the MusicBrainz web service. =head1 DESCRIPTION This module's relationship with WebService::MusicBrainz::Artist, WebService::MusicBrainz::Release, and WebService::MusicBrainz::Track is a "has a" relationship. This module will not be instantiated by any client but will only be used internally within the Artist, Release, or Track classes. =head1 METHODS =head2 new() This method is the constructor and it will call for initialization. An optional HOST parameter can be passed to select a different mirrored server. =cut sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_init(@_); return $self; } sub _init { my $self = shift; my %params = @_; my $web_service_uri = URI->new(); my $web_service_uri_scheme = "http"; my $web_service_host = $params{HOST} || 'musicbrainz.org'; my $web_service_namespace = 'ws'; my $web_service_version = '1'; $web_service_uri->scheme($web_service_uri_scheme); $web_service_uri->host($web_service_host); $web_service_uri->path("$web_service_namespace/$web_service_version/"); $self->{_baseurl} = $web_service_uri->as_string(); } =head2 set_url_params() Define a list of valid URL query parameters. =cut sub set_url_params { my $self = shift; my @params = @_; foreach my $p (@params) { push @{ $self->{_valid_url_params} }, lc($p); } } =head2 set_inc_params() Define a list of valid arguments for the "inc" URL query parameter. =cut sub set_inc_params { my $self = shift; my @params = @_; foreach my $p (@params) { push @{ $self->{_valid_inc_params} }, lc($p); } } sub _url { my $self = shift; my $class = shift; my $params = shift; $self->_validate_params($params); my $url = $self->{_baseurl} . $class . '/'; $url .= $params->{MBID} if $params->{MBID}; $url .= '?type=xml'; foreach my $key (keys %{ $params }) { $url .= '&' . lc($key) . '=' . $params->{$key} unless lc($key) eq "mbid"; } # warn "URL: $url\n"; return $url; } =head2 get() Perform the URL request (GET) and if success, then return a WebService::MusicBrainz::Response object. Otherwise die. =cut sub get { my $self = shift; my $class = shift; my $params = shift; my $url = $self->_url($class, $params); my $ua = LWP::UserAgent->new(); $ua->env_proxy(); $ua->agent("WebService::MusicBrainz/$VERSION"); my $response = $ua->get($url); if($response->code() eq "200") { my $r = WebService::MusicBrainz::Response->new( XML => $response->content ); return $r; } die "URL (", $url, ") Request Failed - Code: ", $response->code(), " Error: ", $response->message(), "\n"; } sub _validate_params { my $self = shift; my $params = shift; foreach my $key (sort keys %{ $params }) { my $valid = 0; my @new_terms; foreach my $term (split /[\s\+,]/, $params->{$key}) { push @new_terms, URI::Escape::uri_escape_utf8($term); } $params->{$key} = join '+', @new_terms; if(lc($key) eq "inc") { foreach my $iparam (split /[\s,]/, $params->{INC}) { foreach my $vparam (@{ $self->{_valid_inc_params} }) { if((lc($iparam) eq lc($vparam)) || ($iparam =~ m/^$vparam/)) { $valid = 1; last; } } } } else { foreach my $vparam (@{ $self->{_valid_url_params} }) { if(lc($key) eq lc($vparam)) { $valid = 1; last; } } } if($valid == 0) { die "Invalid parameter : $key"; } } return $params; } =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Label.pm0000444000175000017500000000530411304125306023633 0ustar bfaistbfaistpackage WebService::MusicBrainz::Label; use strict; use WebService::MusicBrainz::Query; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Label =head1 SYNOPSIS use WebService::MusicBrainz::Label; my $ws = WebService::MusicBrainz::Label->new(); my $response = $ws->search({ NAME => 'warner music' }); my $label = $response->label(); # get first in list print $label->name(), " ", $artist->type(), "\n"; # OUTPUT: Warner Music Australia Distributor =head1 DESCRIPTION This module is used to query an artist from the MusicBrainz web service. =head1 METHODS =head2 new() This method is the constructor and it will make a call for initialization. my $ws = WebService::MusicBrainz::Label->new(); =cut sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_init(@_); return $self; } sub _init { my $self = shift; my $q = WebService::MusicBrainz::Query->new(@_); $q->set_url_params(qw/mbid name limit offset query/); $q->set_inc_params(qw/aliases artist-rels label-rels release-rels track-rels url-rels/); $self->{_query} = $q; } =head2 query() This method returns the cached WebService::MusicBrainz::Query object. =cut sub query { my $self = shift; return $self->{_query}; } =head2 search() This method will perform the search of the MusicBrainz database through their web service schema and return a response object. my $ws = WebService::MusicBrainz::Label->new(); my $response = $ws->search({ MBID => 'd15721d8-56b4-453d-b506-fc915b14cba2' }); my $response = $ws->search({ NAME => 'throwing muses' }); my $response = $ws->search({ NAME => 'james', LIMIT => 5 }); my $response = $ws->search({ NAME => 'beatles', OFFSET => 5 }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'aliases' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'artist-rels' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'release-rels' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'track-rels' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'url-rels' }); =cut sub search { my $self = shift; my $params = shift; my $response = $self->query()->get('label', $params); return $response; } =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2007 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/0000755000175000017500000000000011304125306024054 5ustar bfaistbfaistWebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/ArtistList.pm0000444000175000017500000000151711304125306026516 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::ArtistList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::ArtistList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 artists() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/artists count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/ReleaseEventList.pm0000444000175000017500000000153111304125306027626 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::ReleaseEventList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::ReleaseEventList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 events() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/events count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/ReleaseGroup.pm0000444000175000017500000000162711304125306027013 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::ReleaseGroup; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::ReleaseGroup =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 id() =head2 type() =head2 title() =head2 artist() =head2 release_list() =head2 score() =cut __PACKAGE__->mk_accessors(qw/id type title artist release_list score/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Release.pm0000444000175000017500000000247111304125306025774 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Release; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Release =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 id() =head2 type() =head2 title() =head2 text_rep_language() =head2 text_rep_script() =head2 asin() =head2 artist() =head2 release_event_list() =head2 disc_list() =head2 puid_list() =head2 track_list() =head2 relation_list() =head2 relation_lists() =head2 tag_list() =head2 user_tag_list() =head2 rating() =head2 user_rating() =head2 score() =cut __PACKAGE__->mk_accessors(qw/id type title text_rep_language text_rep_script asin artist release_group release_event_list disc_list puid_list track_list relation_list relation_lists tag_list user_tag_list rating user_rating score/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/ISRC.pm0000444000175000017500000000143711304125306025155 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::ISRC; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::ISRC =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 id() =head2 name() =cut __PACKAGE__->mk_accessors(qw/id name/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/LabelList.pm0000444000175000017500000000151311304125306026263 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::LabelList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::LabelList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 labels() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/labels count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Disc.pm0000444000175000017500000000144511304125306025276 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Disc; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Disc =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 id() =head2 sectors() =cut __PACKAGE__->mk_accessors(qw/id sectors/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/UserRating.pm0000444000175000017500000000143511304125306026476 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::UserRating; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::UserRating =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 value() =cut __PACKAGE__->mk_accessors(qw/value/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Label.pm0000444000175000017500000000245011304125306025430 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Label; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Label =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without an argument, they will return that state if it is available. =head2 id() =head2 type() =head2 name() =head2 sort_name() =head2 label_code() =head2 disambiguation() =head2 country() =head2 life_span_begin() =head2 life_span_end() =head2 alias_list() =head2 release_list() =head2 relation_list() =head2 relation_lists() =head2 tag_list() =head2 user_tag_list() =head2 rating() =head2 user_rating() =head2 score() =cut __PACKAGE__->mk_accessors(qw/id type name sort_name label_code disambiguation country life_span_begin life_span_end alias_list release_list relation_list relation_lists tag_list user_tag_list rating user_rating score/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/RelationList.pm0000444000175000017500000000157111304125306027025 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::RelationList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::RelationList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 relations() =head2 target-type() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/relations target_type count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/UserTagList.pm0000444000175000017500000000152111304125306026615 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::UserTagList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::TagList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 user_tags() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/user_tags count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Puid.pm0000444000175000017500000000141311304125306025310 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Puid; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Puid =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 id() =cut __PACKAGE__->mk_accessors(qw/id/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Metadata.pm0000444000175000017500000000206611304125306026134 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Metadata; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Metadata =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 generator() =head2 created() =head2 artist() =head2 release() =head2 release_group() =head2 track() =head2 artist_list() =head2 release_list() =head2 track_list() =head2 score() =cut __PACKAGE__->mk_accessors(qw/generator created artist release release_group track label artist_list release_list track_list label_list score/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/UserTag.pm0000444000175000017500000000142711304125306025766 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::UserTag; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::UserTag =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 value() =cut __PACKAGE__->mk_accessors(qw/value/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/PuidList.pm0000444000175000017500000000150711304125306026150 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::PuidList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::PuidList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 puids() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/puids count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Relation.pm0000444000175000017500000000177111304125306026173 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Relation; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Relation =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 type() =head2 target() =head2 direction() =head2 attributes() =head2 begin() =head2 end() =head2 artist() =head2 release() =head2 track() =head2 score() =cut __PACKAGE__->mk_accessors(qw/type target direction attributes begin end artist release track label score/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Artist.pm0000444000175000017500000000244011304125306025656 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Artist; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Artist =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without an argument, they will return that state if it is available. =head2 id() =head2 type() =head2 name() =head2 sort_name() =head2 disambiguation() =head2 life_span_begin() =head2 life_span_end() =head2 alias_list() =head2 release_list() =head2 release_group_list() =head2 relation_list() =head2 relation_lists() =head2 tag_list() =head2 user_tag_list() =head2 rating() =head2 user_rating() =head2 score() =cut __PACKAGE__->mk_accessors(qw/id type name sort_name disambiguation life_span_begin life_span_end alias_list release_list release_group_list relation_list relation_lists tag_list user_tag_list rating user_rating score/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Track.pm0000444000175000017500000000220311304125306025451 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Track; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Track =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 id() =head2 title() =head2 duration() =head2 artist() =head2 release_list() =head2 puid_list() =head2 relation_list() =head2 relation_lists() =head2 tag_list() =head2 user_tag_list() =head2 rating() =head2 user_rating() =head2 score() =cut __PACKAGE__->mk_accessors(qw/id title duration isrc_list artist release_list puid_list relation_list relation_lists tag_list user_tag_list rating user_rating score/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/ReleaseList.pm0000444000175000017500000000152311304125306026625 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::ReleaseList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::ReleaseList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 releases() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/releases count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/DiscList.pm0000444000175000017500000000150711304125306026131 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::DiscList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::DiscList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 discs() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/discs count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/AliasList.pm0000444000175000017500000000151511304125306026277 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::AliasList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::AliasList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 aliases() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/aliases count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/ReleaseGroupList.pm0000444000175000017500000000155111304125306027643 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::ReleaseGroupList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::ReleaseGroupList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 count() =head2 offset() =head2 release_groups() =cut __PACKAGE__->mk_accessors(qw/count offset release_groups/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/ReleaseEvent.pm0000444000175000017500000000165211304125306026776 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::ReleaseEvent; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::ReleaseEvent =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 date() =head2 country() =head2 label() =head2 catalog_number() =head2 barcode() =head2 format() =cut __PACKAGE__->mk_accessors(qw/date country label catalog_number barcode format/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/TagList.pm0000444000175000017500000000150311304125306025756 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::TagList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::TagList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 tags() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/tags count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/ISRCList.pm0000444000175000017500000000150711304125306026007 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::ISRCList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::ISRCList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 isrcs() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/isrcs count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Tag.pm0000444000175000017500000000144311304125306025125 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Tag; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Tag =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 count() =head2 text() =cut __PACKAGE__->mk_accessors(qw/text count/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Alias.pm0000444000175000017500000000147511304125306025450 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Alias; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Alias =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 type() =head2 script() =head2 text() =cut __PACKAGE__->mk_accessors(qw/type script text/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/TrackList.pm0000444000175000017500000000151311304125306026310 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::TrackList; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::TrackList =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 tracks() =head2 count() =head2 offset() =cut __PACKAGE__->mk_accessors(qw/tracks count offset/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response/Rating.pm0000444000175000017500000000146711304125306025644 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response::Rating; use strict; use base 'Class::Accessor'; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response::Rating =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS All the methods listed below are accessor methods. They can take a scalar argument to set the state of the object or without and argument, they will return that state if it is available. =head2 votes_count() =head2 value() =cut __PACKAGE__->mk_accessors(qw/votes_count value/); =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Response.pm0000444000175000017500000007277711304125306024434 0ustar bfaistbfaistpackage WebService::MusicBrainz::Response; use strict; use XML::LibXML; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Response =head1 SYNOPSIS =head1 DESCRIPTION This module will hide the details of the XML web service response and provide an API to query the XML data which has been returned. This module is responsible for parsing the XML web service response and instantiating objects to provide access to the details of the response. =head1 METHODS =head2 new() This method is the constructor and it will call for initialization. =cut sub new { my $class = shift; my %params = @_; my $self = {}; bless $self, $class; $self->{_xml} = $params{XML} || die "XML parameter required"; $self->_load_xml(); $self->_init(); return $self; } sub _load_xml { my $self = shift; my $parser = XML::LibXML->new(); my $document = $parser->parse_string($self->{_xml}) or die "Failure to parse XML"; my $root = $document->getDocumentElement(); my $xpc = XML::LibXML::XPathContext->new($root); $xpc->registerNs('mmd', $root->getAttribute('xmlns')); $xpc->registerNs('ext', $root->getAttribute('xmlns:ext')) if $root->getAttribute('xmlns:ext'); $self->{_xmlobj} = $xpc; $self->{_xmlroot} = $root; return; } =head2 xpc() =cut sub xpc { my $self = shift; return $self->{_xmlobj}; } =head2 as_xml() This method returns the raw XML from the MusicBrainz web service response. =cut sub as_xml { my $self = shift; return $self->{_xmlroot}->toString(); } sub _init { my $self = shift; my $xpc = $self->xpc() || return; my ($xArtist) = $xpc->findnodes('mmd:artist[1]'); my ($xArtistList) = $xpc->findnodes('mmd:artist-list[1]'); my ($xRelease) = $xpc->findnodes('mmd:release[1]'); my ($xReleaseList) = $xpc->findnodes('mmd:release-list[1]'); my ($xTrack) = $xpc->findnodes('mmd:track[1]'); my ($xTrackList) = $xpc->findnodes('mmd:track-list[1]'); my ($xLabel) = $xpc->findnodes('mmd:label[1]'); my ($xLabelList) = $xpc->findnodes('mmd:label-list[1]'); my ($xReleaseGroupList) = $xpc->findnodes('mmd:release-group-list[1]'); require WebService::MusicBrainz::Response::Metadata; my $metadata = WebService::MusicBrainz::Response::Metadata->new(); $metadata->generator( $xpc->find('@generator')->pop()->getValue() ) if $xpc->find('@generator'); $metadata->created( $xpc->find('@created')->pop()->getValue() ) if $xpc->find('@created'); $metadata->score( $xpc->find('@ext:score')->pop()->getValue() ) if $xpc->lookupNs('ext') && $xpc->find('@ext:score'); $metadata->artist( $self->_create_artist( $xArtist ) ) if $xArtist; $metadata->artist_list( $self->_create_artist_list( $xArtistList ) ) if $xArtistList; $metadata->release( $self->_create_release( $xRelease ) ) if $xRelease; $metadata->release_list( $self->_create_release_list( $xReleaseList ) ) if $xReleaseList; $metadata->track( $self->_create_track( $xTrack ) ) if $xTrack; $metadata->track_list( $self->_create_track_list( $xTrackList ) ) if $xTrackList; $metadata->label( $self->_create_label( $xLabel ) ) if $xLabel; $metadata->label_list( $self->_create_label_list( $xLabelList ) ) if $xLabelList; $metadata->release_group_list( $self->_create_release_group_list( $xReleaseGroupList ) ) if $xReleaseGroupList; $self->{_metadata_cache} = $metadata; } =head2 generator() This method will return an optional value of the generator. =cut sub generator { my $self = shift; my $metadata = $self->{_metadata_cache}; return $metadata->generator(); } =head2 created() This method will return an optional value of the created date. =cut sub created { my $self = shift; my $metadata = $self->{_metadata_cache}; return $metadata->created(); } =head2 score() This method will return an optional value of the relevance score. =cut sub score { my $self = shift; my $metadata = $self->{_metadata_cache}; return $metadata->score(); } =head2 metadata() This method will return an Response::Metadata object. =cut sub metadata { my $self = shift; my $metadata = $self->{_metadata_cache}; return $metadata; } =head2 artist() This method will return an Response::Artist object. =cut sub artist { my $self = shift; my $metadata = $self->{_metadata_cache}; my $artist = $metadata->artist_list() ? $metadata->artist_list()->artists()->[0] : $metadata->artist(); return $artist; } =head2 release() This method will return an Reponse::Release object;. =cut sub release { my $self = shift; my $metadata = $self->{_metadata_cache}; my $release = $metadata->release_list() ? $metadata->release_list()->releases()->[0] : $metadata->release(); return $release; } =head2 track() This method will return an Response::Track object. =cut sub track { my $self = shift; my $metadata = $self->{_metadata_cache}; my $track = $metadata->track_list() ? $metadata->track_list()->tracks()->[0] : $metadata->track(); return $track; } =head2 label() This method will return an Response::Label object. =cut sub label { my $self = shift; my $metadata = $self->{_metadata_cache}; my $label = $metadata->label_list() ? $metadata->label_list()->labels()->[0] : $metadata->label(); return $label; } =head2 artist_list() This method will return a reference to the Response::ArtistList object in a scalar context. If in a array context, an array of Response::Artist objects will be returned. =cut sub artist_list { my $self = shift; my $metadata = $self->{_metadata_cache}; my $artist_list = $metadata->artist_list(); return wantarray ? @{ $artist_list->artists() } : $artist_list; } =head2 release_list() This method will return a reference to the Response::ReleaseList object in a scalar context. If in a array context, an array of Response::Release objects will be returned. =cut sub release_list { my $self = shift; my $metadata = $self->{_metadata_cache}; my $release_list = $metadata->release_list(); return wantarray ? @{ $release_list->releases() } : $release_list; } =head2 track_list() This method will return a reference to the Response::TrackList object in a scalar context. If in a array context, an array of Response::Track objects will be returned. =cut sub track_list { my $self = shift; my $metadata = $self->{_metadata_cache}; my $track_list = $metadata->track_list(); return wantarray ? @{ $track_list->tracks() } : $track_list; } =head2 label_list() This method will return a reference to the Response::LabelList object in a scalar context. If in a array context, an array of Response::Label objects will be returned. =cut sub label_list { my $self = shift; my $metadata = $self->{_metadata_cache}; my $label_list = $metadata->label_list(); return wantarray ? @{ $label_list->labels() } : $label_list; } sub _create_artist { my $self = shift; my ($xArtist) = @_; my $xpc = $self->xpc(); my ($xSortName) = $xpc->findnodes('mmd:sort-name[1]', $xArtist); my ($xName) = $xpc->findnodes('mmd:name[1]', $xArtist); my ($xDisambiguation) = $xpc->findnodes('mmd:disambiguation[1]', $xArtist); my ($xLifeSpan) = $xpc->findnodes('mmd:life-span[1]', $xArtist); my ($xAliasList) = $xpc->findnodes('mmd:alias-list[1]', $xArtist); my @xRelationList = $xpc->findnodes('mmd:relation-list', $xArtist); my ($xReleaseList) = $xpc->findnodes('mmd:release-list[1]', $xArtist); my ($xTagList) = $xpc->findnodes('mmd:tag-list[1]', $xArtist); my ($xReleaseGroupList) = $xpc->findnodes('mmd:release-group-list[1]', $xArtist); my ($xRating) = $xpc->findnodes('mmd:rating[1]', $xArtist); require WebService::MusicBrainz::Response::Artist; my $artist = WebService::MusicBrainz::Response::Artist->new(); $artist->id( $xArtist->getAttribute('id') ) if $xArtist->getAttribute('id'); $artist->type( $xArtist->getAttribute('type') ) if $xArtist->getAttribute('type'); $artist->name( $xName->textContent() ) if $xName; $artist->sort_name( $xSortName->textContent() ) if $xSortName; $artist->disambiguation( $xDisambiguation->textContent() ) if $xDisambiguation; $artist->life_span_begin( $xLifeSpan->getAttribute('begin') ) if $xLifeSpan && $xLifeSpan->getAttribute('begin'); $artist->life_span_end( $xLifeSpan->getAttribute('end') ) if $xLifeSpan && $xLifeSpan->getAttribute('end'); $artist->score( $xArtist->getAttribute('ext:score') ) if $xArtist->getAttribute('ext:score'); $artist->alias_list( $self->_create_alias_list( $xAliasList ) ) if $xAliasList; $artist->release_list( $self->_create_release_list( $xReleaseList ) ) if $xReleaseList; $artist->tag_list( $self->_create_tag_list( $xTagList ) ) if $xTagList; my $relationLists = $self->_create_relation_lists( \@xRelationList ); $artist->relation_list( $relationLists->[0] ) if $relationLists; $artist->relation_lists( $relationLists ) if $relationLists; $artist->release_group_list( $self->_create_release_group_list( $xReleaseGroupList ) ) if $xReleaseGroupList; $artist->rating( $self->_create_rating( $xRating ) ) if $xRating; return $artist; } sub _create_artist_list { my $self = shift; my ($xArtistList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::ArtistList; my $artist_list = WebService::MusicBrainz::Response::ArtistList->new(); $artist_list->count( $xArtistList->getAttribute('count') ) if $xArtistList->getAttribute('count'); $artist_list->offset( $xArtistList->getAttribute('offset') ); my @artists; foreach my $xArtist ($xpc->findnodes('mmd:artist', $xArtistList)) { my $artist = $self->_create_artist( $xArtist ); push @artists, $artist; } $artist_list->artists( \@artists ); return $artist_list; } sub _create_release { my $self = shift; my ($xRelease) = @_; my $xpc = $self->xpc(); my ($xTitle) = $xpc->findnodes('mmd:title[1]', $xRelease); my ($xTextRep) = $xpc->findnodes('mmd:text-representation[1]', $xRelease); my ($xASIN) = $xpc->findnodes('mmd:asin[1]', $xRelease); my ($xArtist) = $xpc->findnodes('mmd:artist[1]', $xRelease); my ($xReleaseEventList) = $xpc->findnodes('mmd:release-event-list[1]', $xRelease); my ($xDiscList) = $xpc->findnodes('mmd:disc-list[1]', $xRelease); my ($xPuidList) = $xpc->findnodes('mmd:puid-list[1]', $xRelease); my ($xTrackList) = $xpc->findnodes('mmd:track-list[1]', $xRelease); my @xRelationList = $xpc->findnodes('mmd:relation-list', $xRelease); my ($xTagList) = $xpc->findnodes('mmd:tag-list[1]', $xRelease); my ($xReleaseGroup) = $xpc->findnodes('mmd:release-group[1]', $xRelease); # my ($xUserTagList) = $xpc->findnodes('mmd:user-tag-list[1]', $xRelease); my ($xRating) = $xpc->findnodes('mmd:rating[1]', $xRelease); # my ($xUserRating) = $xpc->findnodes('mmd:user-rating[1]', $xRelease); require WebService::MusicBrainz::Response::Release; my $release = WebService::MusicBrainz::Response::Release->new(); $release->id( $xRelease->getAttribute('id') ) if $xRelease->getAttribute('id'); $release->type( $xRelease->getAttribute('type') ) if $xRelease->getAttribute('type'); $release->title( $xTitle->textContent() ) if $xTitle; $release->text_rep_language( $xTextRep->getAttribute('language') ) if $xTextRep && $xTextRep->getAttribute('language'); $release->text_rep_script( $xTextRep->getAttribute('script') ) if $xTextRep && $xTextRep->getAttribute('script'); $release->asin( $xASIN->textContent() ) if $xASIN; $release->score( $xRelease->getAttribute('ext:score') ) if $xRelease->getAttribute('ext:score'); $release->artist( $self->_create_artist( $xArtist ) ) if $xArtist; $release->release_event_list( $self->_create_release_event_list( $xReleaseEventList ) ) if $xReleaseEventList; $release->release_group( $self->_create_release_group( $xReleaseGroup ) ) if $xReleaseGroup; $release->disc_list( $self->_create_disc_list( $xDiscList ) ) if $xDiscList; $release->puid_list( $self->_create_puid_list( $xPuidList ) ) if $xPuidList; $release->track_list( $self->_create_track_list( $xTrackList ) ) if $xTrackList; $release->tag_list( $self->_create_tag_list( $xTagList ) ) if $xTagList; # $release->user_tag_list( $self->_create_user_tag_list( $xUserTagList ) ) if $xUserTagList; $release->rating( $self->_create_rating( $xRating ) ) if $xRating; # $release->user_rating( $self->_create_user_rating( $xUserRating ) ) if $xUserRating; my $relationLists = $self->_create_relation_lists( \@xRelationList ); $release->relation_list( $relationLists->[0] ) if $relationLists; $release->relation_lists( $relationLists ) if $relationLists; return $release; } sub _create_track { my $self = shift; my ($xTrack) = @_; my $xpc = $self->xpc(); my ($xTitle) = $xpc->findnodes('mmd:title[1]', $xTrack); my ($xDuration) = $xpc->findnodes('mmd:duration[1]', $xTrack); my ($xArtist) = $xpc->findnodes('mmd:artist[1]', $xTrack); my ($xReleaseList) = $xpc->findnodes('mmd:release-list[1]', $xTrack); my ($xPuidList) = $xpc->findnodes('mmd:puid-list[1]', $xTrack); my ($xISRCList) = $xpc->findnodes('mmd:isrc-list[1]', $xTrack); my @xRelationList = $xpc->findnodes('mmd:relation-list', $xTrack); my ($xTagList) = $xpc->findnodes('mmd:tag-list[1]', $xTrack); require WebService::MusicBrainz::Response::Track; my $track= WebService::MusicBrainz::Response::Track->new(); $track->id( $xTrack->getAttribute('id') ) if $xTrack->getAttribute('id'); $track->title( $xTitle->textContent() ) if $xTitle; $track->duration( $xDuration->textContent() ) if $xDuration; $track->score( $xTrack->getAttribute('ext:score') ) if $xTrack->getAttribute('ext:score'); $track->artist( $self->_create_artist( $xArtist ) ) if $xArtist; $track->release_list( $self->_create_release_list( $xReleaseList ) ) if $xReleaseList; $track->puid_list( $self->_create_puid_list( $xPuidList ) ) if $xPuidList; $track->isrc_list( $self->_create_isrc_list( $xISRCList ) ) if $xISRCList; $track->tag_list( $self->_create_tag_list( $xTagList ) ) if $xTagList; my $relationLists = $self->_create_relation_lists( \@xRelationList ); $track->relation_list( $relationLists->[0] ) if $relationLists; $track->relation_lists( $relationLists ) if $relationLists; return $track; } sub _create_label { my $self = shift; my ($xLabel) = @_; my $xpc = $self->xpc(); my ($xName) = $xpc->findnodes('mmd:name[1]', $xLabel); my ($xSortName) = $xpc->findnodes('mmd:sort-name[1]', $xLabel); my ($xLabelCode) = $xpc->findnodes('mmd:label-code[1]', $xLabel); my ($xDisambiguation) = $xpc->findnodes('mmd:disambiguation[1]', $xLabel); my ($xCountry) = $xpc->findnodes('mmd:country[1]', $xLabel); my ($xLifeSpan) = $xpc->findnodes('mmd:life-span[1]', $xLabel); my ($xAliasList) = $xpc->findnodes('mmd:alias-list[1]', $xLabel); my ($xReleaseList) = $xpc->findnodes('mmd:release-list[1]', $xLabel); my @xRelationList = $xpc->findnodes('mmd:relation-list', $xLabel); my ($xTagList) = $xpc->findnodes('mmd:tag-list[1]', $xLabel); require WebService::MusicBrainz::Response::Label; my $label= WebService::MusicBrainz::Response::Label->new(); $label->id( $xLabel->getAttribute('id') ) if $xLabel->getAttribute('id'); $label->type( $xLabel->getAttribute('type') ) if $xLabel->getAttribute('type'); $label->name( $xName->textContent() ) if $xName; $label->sort_name( $xSortName->textContent() ) if $xSortName; $label->label_code( $xLabelCode->textContent() ) if $xLabelCode; $label->disambiguation( $xDisambiguation->textContent() ) if $xDisambiguation; $label->country( $xCountry->textContent() ) if $xCountry; $label->life_span_begin( $xLifeSpan->getAttribute('begin') ) if $xLifeSpan; $label->life_span_end( $xLifeSpan->getAttribute('end') ) if $xLifeSpan; $label->score( $xLabel->getAttribute('ext:score') ) if $xLabel->getAttribute('ext:score'); $label->alias_list( $self->_create_alias_list( $xAliasList ) ) if $xAliasList; $label->release_list( $self->_create_release_list( $xReleaseList ) ) if $xReleaseList; $label->tag_list( $self->_create_tag_list( $xTagList ) ) if $xTagList; my $relationLists = $self->_create_relation_lists( \@xRelationList ); $label->relation_list( $relationLists->[0] ) if $relationLists; $label->relation_lists( $relationLists ) if $relationLists; return $label; } sub _create_label_list { my $self = shift; my ($xLabelList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::LabelList; my $label_list = WebService::MusicBrainz::Response::LabelList->new(); $label_list->count( $xLabelList->getAttribute('count') ) if $xLabelList->getAttribute('count'); $label_list->offset( $xLabelList->getAttribute('offset') ); my @labels; foreach my $xLabel ($xpc->findnodes('mmd:label', $xLabelList)) { my $label = $self->_create_label( $xLabel ); push @labels, $label; } $label_list->labels( \@labels ); return $label_list; } sub _create_track_list { my $self = shift; my ($xTrackList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::TrackList; my $track_list = WebService::MusicBrainz::Response::TrackList->new(); $track_list->count( $xTrackList->getAttribute('count') ) if $xTrackList->getAttribute('count'); $track_list->offset( $xTrackList->getAttribute('offset') ); my @tracks; foreach my $xTrack ($xpc->findnodes('mmd:track', $xTrackList)) { my $track = $self->_create_track( $xTrack ); push @tracks, $track; } $track_list->tracks( \@tracks ); return $track_list; } sub _create_alias { my $self = shift; my ($xAlias) = @_; require WebService::MusicBrainz::Response::Alias; my $alias = WebService::MusicBrainz::Response::Alias->new(); $alias->type( $xAlias->getAttribute('type') ) if $xAlias->getAttribute('type'); $alias->script( $xAlias->getAttribute('script') ) if $xAlias->getAttribute('script'); $alias->text( $xAlias->textContent() ) if $xAlias->textContent(); return $alias; } sub _create_alias_list { my $self = shift; my ($xAliasList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::AliasList; my $alias_list = WebService::MusicBrainz::Response::AliasList->new(); $alias_list->count( $xAliasList->getAttribute('count') ) if $xAliasList->getAttribute('count'); $alias_list->offset( $xAliasList->getAttribute('offset') ); my @aliases; foreach my $xAlias ($xpc->findnodes('mmd:alias', $xAliasList)) { my $alias = $self->_create_alias($xAlias); push @aliases, $alias if defined($alias); } $alias_list->aliases( \@aliases ); return $alias_list; } sub _create_relation { my $self = shift; my ($xRelation) = @_; my $xpc = $self->xpc(); my ($xArtist) = $xpc->findnodes('mmd:artist[1]', $xRelation); my ($xRelease) = $xpc->findnodes('mmd:release[1]', $xRelation); my ($xTrack) = $xpc->findnodes('mmd:track[1]', $xRelation); my ($xLabel) = $xpc->findnodes('mmd:label[1]', $xRelation); require WebService::MusicBrainz::Response::Relation; my $relation = WebService::MusicBrainz::Response::Relation->new(); $relation->type( $xRelation->getAttribute('type') ) if $xRelation->getAttribute('type'); $relation->target( $xRelation->getAttribute('target') ) if $xRelation->getAttribute('target'); $relation->direction( $xRelation->getAttribute('direction') ) if $xRelation->getAttribute('direction'); $relation->attributes( $xRelation->getAttribute('attributes') ) if $xRelation->getAttribute('attributes'); $relation->begin( $xRelation->getAttribute('begin') ) if $xRelation->getAttribute('begin'); $relation->end( $xRelation->getAttribute('end') ) if $xRelation->getAttribute('end'); $relation->score( $xRelation->getAttribute('ext:score') ) if $xRelation->getAttribute('ext:score'); $relation->artist( $self->_create_artist( $xArtist ) ) if $xArtist; $relation->release( $self->_create_release( $xRelease ) ) if $xRelease; $relation->track( $self->_create_track( $xTrack ) ) if $xTrack; $relation->label( $self->_create_label( $xLabel ) ) if $xLabel; return $relation; } sub _create_relation_lists { my $self = shift; my ($xRelationLists) = @_; my @relation_lists; if($xRelationLists && scalar(@{ $xRelationLists }) > 0) { map { push @relation_lists, $self->_create_relation_list( $_ ) } @$xRelationLists; } return scalar(@relation_lists) > 0 ? \@relation_lists : undef; } sub _create_relation_list { my $self = shift; my ($xRelationList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::RelationList; my $relation_list = WebService::MusicBrainz::Response::RelationList->new(); $relation_list->target_type( $xRelationList->getAttribute('target-type') ) if $xRelationList->getAttribute('target-type'); $relation_list->count( $xRelationList->getAttribute('count') ) if $xRelationList->getAttribute('count'); $relation_list->offset( $xRelationList->getAttribute('offset') ); my @relations; foreach my $xRelation ($xpc->findnodes('mmd:relation', $xRelationList)) { my $relation = $self->_create_relation($xRelation); push @relations, $relation if defined($relation); } $relation_list->relations( \@relations ); return $relation_list; } sub _create_event { my $self = shift; my ($xEvent) = @_; my $xpc = $self->xpc(); my ($xLabel) = $xpc->findnodes('mmd:label[1]', $xEvent); require WebService::MusicBrainz::Response::ReleaseEvent; my $event = WebService::MusicBrainz::Response::ReleaseEvent->new(); $event->date( $xEvent->getAttribute('date') ) if $xEvent->getAttribute('date'); $event->country( $xEvent->getAttribute('country') ) if $xEvent->getAttribute('country'); $event->label( $self->_create_label($xLabel) ) if $xLabel; $event->catalog_number( $xEvent->getAttribute('catalog-number') ) if $xEvent->getAttribute('catalog-number'); $event->barcode( $xEvent->getAttribute('barcode') ) if $xEvent->getAttribute('barcode'); $event->format( $xEvent->getAttribute('format') ) if $xEvent->getAttribute('format'); return $event; } sub _create_release_event_list { my $self = shift; my ($xReleaseEventList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::ReleaseEventList; my $release_event_list = WebService::MusicBrainz::Response::ReleaseEventList->new(); $release_event_list->count( $xReleaseEventList->getAttribute('count') ) if $xReleaseEventList->getAttribute('count'); $release_event_list->offset( $xReleaseEventList->getAttribute('offset') ); my @events; foreach my $xEvent ($xpc->findnodes('mmd:event', $xReleaseEventList)) { my $event = $self->_create_event( $xEvent ); push @events, $event; } # should use a date object here but cheating with cmp to reduce dependencies for now... my @sorted_events = sort { $a->date() cmp $b->date() } @events; $release_event_list->events( \@sorted_events ); return $release_event_list; } sub _create_release_list { my $self = shift; my ($xReleaseList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::ReleaseList; my $release_list = WebService::MusicBrainz::Response::ReleaseList->new(); $release_list->count( $xReleaseList->getAttribute('count') ) if $xReleaseList->getAttribute('count'); $release_list->offset( $xReleaseList->getAttribute('offset') ); my @releases; foreach my $xRelease ($xpc->findnodes('mmd:release', $xReleaseList)) { my $release = $self->_create_release($xRelease); push @releases, $release if defined($release); } $release_list->releases( \@releases ); return $release_list; } sub _create_disc { my $self = shift; my ($xDisc) = @_; require WebService::MusicBrainz::Response::Disc; my $disc = WebService::MusicBrainz::Response::Disc->new(); $disc->id( $xDisc->getAttribute('id') ) if $xDisc->getAttribute('id'); $disc->sectors( $xDisc->getAttribute('sectors') ) if $xDisc->getAttribute('sectors'); return $disc; } sub _create_disc_list { my $self = shift; my ($xDiscList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::DiscList; my $disc_list = WebService::MusicBrainz::Response::DiscList->new(); my @discs; $disc_list->count( $xDiscList->getAttribute('count') ) if $xDiscList->getAttribute('count'); $disc_list->offset( $xDiscList->getAttribute('offset') ); foreach my $xDisc ($xpc->findnodes('mmd:disc', $xDiscList)) { my $disc = $self->_create_disc( $xDisc ); push @discs, $disc; } $disc_list->discs( \@discs ); return $disc_list; } sub _create_puid { my $self = shift; my ($xPuid) = @_; require WebService::MusicBrainz::Response::Puid; my $puid = WebService::MusicBrainz::Response::Puid->new(); $puid->id( $xPuid->getAttribute('id') ) if $xPuid->getAttribute('id'); return $puid; } sub _create_puid_list { my $self = shift; my ($xPuidList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::PuidList; my $puid_list = WebService::MusicBrainz::Response::PuidList->new(); $puid_list->count( $xPuidList->getAttribute('count') ) if $xPuidList->getAttribute('count'); $puid_list->offset( $xPuidList->getAttribute('offset') ); my @puids; foreach my $xPuid ($xpc->findnodes('mmd:puid', $xPuidList)) { my $puid = $self->_create_puid( $xPuid ); push @puids, $puid; } $puid_list->puids( \@puids ); return $puid_list; } sub _create_tag { my $self = shift; my ($xTag) = @_; require WebService::MusicBrainz::Response::Tag; my $tag = WebService::MusicBrainz::Response::Tag->new(); $tag->id( $xTag->getAttribute('id') ) if $xTag->getAttribute('id'); $tag->count( $xTag->getAttribute('count') ) if $xTag->getAttribute('count'); $tag->text( $xTag->textContent() ) if $xTag->textContent(); return $tag; } sub _create_tag_list { my $self = shift; my ($xTagList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::TagList; my $tag_list = WebService::MusicBrainz::Response::TagList->new(); $tag_list->count( $xTagList->getAttribute('count') ) if $xTagList->getAttribute('count'); $tag_list->offset( $xTagList->getAttribute('offset') ); my @tags; foreach my $xTag ($xpc->findnodes('mmd:tag', $xTagList)) { my $tag = $self->_create_tag( $xTag ); push @tags, $tag; } $tag_list->tags( \@tags ); return $tag_list; } sub _create_isrc { my $self = shift; my ($xIsrc) = @_; require WebService::MusicBrainz::Response::ISRC; my $isrc = WebService::MusicBrainz::Response::ISRC->new(); $isrc->id( $xIsrc->getAttribute('id') ) if $xIsrc->getAttribute('id'); return $isrc; } sub _create_isrc_list { my $self = shift; my ($xIsrcList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::ISRCList; my $isrc_list = WebService::MusicBrainz::Response::ISRCList->new(); $isrc_list->count( $xIsrcList->getAttribute('count') ) if $xIsrcList->getAttribute('count'); $isrc_list->offset( $xIsrcList->getAttribute('offset') ); my @isrcs; foreach my $xIsrc ($xpc->findnodes('mmd:isrc', $xIsrcList)) { my $isrc = $self->_create_isrc( $xIsrc ); push @isrcs, $isrc; } $isrc_list->isrcs( \@isrcs ); return $isrc_list; } sub _create_release_group { my $self = shift; my ($xReleaseGroup) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::ReleaseGroup; my $rel_group = WebService::MusicBrainz::Response::ReleaseGroup->new(); $rel_group->id( $xReleaseGroup->getAttribute('id') ) if $xReleaseGroup->getAttribute('id'); $rel_group->type( $xReleaseGroup->getAttribute('type') ) if $xReleaseGroup->getAttribute('type'); my ($xTitle) = $xpc->findnodes('mmd:title[1]', $xReleaseGroup); $rel_group->title( $xTitle->textContent() ) if $xTitle; my ($xArtist) = $xpc->findnodes('mmd:artist[1]', $xReleaseGroup); my ($xReleaseList) = $xpc->findnodes('mmd:release-list[1]', $xReleaseGroup); $rel_group->artist( $self->_create_artist( $xArtist ) ) if $xArtist; $rel_group->release_list( $self->_create_release_list( $xReleaseList ) ) if $xReleaseList; return $rel_group; } sub _create_release_group_list { my $self = shift; my ($xReleaseGroupList) = @_; my $xpc = $self->xpc(); require WebService::MusicBrainz::Response::ReleaseGroupList; my $rel_group_list = WebService::MusicBrainz::Response::ReleaseGroupList->new(); $rel_group_list->count( $xReleaseGroupList->getAttribute('count') ) if $xReleaseGroupList->getAttribute('count'); $rel_group_list->offset( $xReleaseGroupList->getAttribute('offset') ); $rel_group_list->score( $xReleaseGroupList->getAttribute('ext:score') ) if $xReleaseGroupList->getAttribute('ext:score'); my @rel_groups; foreach my $xReleaseGroup ($xpc->findnodes('mmd:release-group', $xReleaseGroupList)) { my $rel_group = $self->_create_release_group( $xReleaseGroup ); push @rel_groups, $rel_group; } $rel_group_list->release_groups( \@rel_groups ); return $rel_group_list; } sub _create_rating { my $self = shift; my ($xRating) = @_; require WebService::MusicBrainz::Response::Rating; my $rating = WebService::MusicBrainz::Response::Rating->new(); $rating->votes_count( $xRating->getAttribute('votes-count') ) if $xRating->getAttribute('votes-count'); $rating->value( $xRating->textContent() ) if $xRating->textContent(); return $rating; } =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2007 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Artist.pm0000444000175000017500000001423211304125306024062 0ustar bfaistbfaistpackage WebService::MusicBrainz::Artist; use strict; use WebService::MusicBrainz::Query; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Artist =head1 SYNOPSIS use WebService::MusicBrainz::Artist; my $ws = WebService::MusicBrainz::Artist->new(); my $response = $ws->search({ NAME => 'white lion' }); my $artist = $response->artist(); # get first in list print $artist->name(), " ", $artist->life_span_begin(), "-", $artist->life_span_end(), "\n"; # OUTPUT: White Lion 1983-1991 =head1 DESCRIPTION This module is used to query an artist from the MusicBrainz web service. =head1 METHODS =head2 new() This method is the constructor and it will make a call for initialization. This method will take an optional HOST parameter to specify a mirrored server. The default is "musicbrainz.org". my $ws = WebService::MusicBrainz::Artist->new(HOST => 'de.musicbrainz.org'); =cut sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_init(@_); return $self; } sub _init { my $self = shift; my $q = WebService::MusicBrainz::Query->new(@_); $q->set_url_params(qw/mbid name limit offset query/); $q->set_inc_params(qw/aliases release-groups artist-rels release-rels track-rels url-rels sa- va- label-rels tags ratings user-tags user-ratings counts release-events discs labels/); $self->{_query} = $q; } =head2 query() This method returns the cached WebService::MusicBrainz::Query object. =cut sub query { my $self = shift; return $self->{_query}; } =head2 search() This method will perform the search of the MusicBrainz database through their web service schema and return a response object. my $ws = WebService::MusicBrainz::Artist->new(); my $response = $ws->search({ MBID => 'd15721d8-56b4-453d-b506-fc915b14cba2' }); my $response = $ws->search({ NAME => 'throwing muses' }); my $response = $ws->search({ NAME => 'james', LIMIT => 5 }); my $response = $ws->search({ NAME => 'beatles', OFFSET => 5 }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'aliases' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'artist-rels' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'release-rels' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'track-rels' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'url-rels' }); Multiple INC params can be delimited by whitespace, commas, or + characters. my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'aliases url-rels' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'aliases,url-rels' }); my $response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'aliases+url-rels' }); =head3 Find a single artist by MBID my $mbid_response = $ws->search({ MBID => '4eca1aa0-c79f-481b-af8a-4a2d6c41aa5c' }); =head3 Find a artist(s) by name my $name_response = $ws->search({ NAME => 'Pantera' }); =head3 Find a artist(s) by name and limit results my $name_limit_response = $ws->search({ NAME => 'Elvis', LIMIT => 3 }); =head3 Find a artist(s) by name and offset my $name_offset_response = $ws->search({ NAME => 'Elvis', OFFSET => 10 }); =head3 Find a artist by MBID and include aliases my $mbid_aliases_response = $ws->search({ MBID => '070d193a-845c-479f-980e-bef15710653e', INC => 'aliases' }); =head3 Find a artist by MBID and include release groups my $mbid_release_groups_response = $ws->search({ MBID => '4dca4bb2-23ba-4103-97e6-5810311db33a', INC => 'release-groups sa-Album' }); =head3 Find a artist by MBID and include artist relations my $mbid_artist_rels_response = $ws->search({ MBID => 'ae1b47d5-5128-431c-9d30-e08fd90e0767', INC => 'artist-rels' }); =head3 Find a artist by MBID and include label relations my $mbid_label_rels_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'label-rels+sa-Official' }); =head3 Find a artist by MBID and include release relations my $mbid_release_rels_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'release-rels' }); =head3 Find a artist by MBID and include track relations my $mbid_track_rels_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'track-rels' }); =head3 Find a artist by MBID and include URL relations my $mbid_url_rels_response = $ws->search({ MBID => 'ae1b47d5-5128-431c-9d30-e08fd90e0767', INC => 'url-rels' }); =head3 Find a artist by MBID and include tags my $mbid_tags_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'tags' }); =head3 Find a artist by MBID and include ratings my $mbid_ratings_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'ratings' }); =head3 Find a artist by MBID and include counts my $mbid_counts_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'counts+sa-Official' }); =head3 Find a artist by MBID and include release events my $mbid_rel_events_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'release-events+sa-Official' }); =head3 Find a artist by MBID and include discs my $mbid_discs_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'discs+sa-Official' }); =head3 Find a artist by MBID and include labels my $mbid_labels_response = $ws->search({ MBID => '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab', INC => 'labels+release-events+sa-Official' }); =head3 Find a artist by direct Lucene query my $q1_response = $ws->search({ QUERY => 'begin:1990 AND type:group'}); =cut sub search { my $self = shift; my $params = shift; my $response = $self->query()->get('artist', $params); return $response; } =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2009 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz/Track.pm0000444000175000017500000000717211304125306023665 0ustar bfaistbfaistpackage WebService::MusicBrainz::Track; use strict; use WebService::MusicBrainz::Query; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz::Track =head1 SYNOPSIS use WebService::MusicBrainz::Track; my $ws = WebService::MusicBrainz::Track->new(); my $response = $ws->search({ TITLE => 'Same in any language' }); my $track = $response->track(); # grab the first one from list print $track->title(), " - ", $track->artist()->name(), "\n"; # OUTPUT: Same In Any Language - I Nine =head1 DESCRIPTION This module is used to search the MusicBrainz database about track information. =head1 METHODS =head2 new() This method is the constructor and it will call for initialization. =cut sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_init(@_); return $self; } sub _init { my $self = shift; my $q = WebService::MusicBrainz::Query->new(@_); $q->set_url_params(qw/mbid title artist release duration tracknum artistid releaseid puid limit offset query/); $q->set_inc_params(qw/artist releases puids artist-rels release-rels track-rels url-rels/); $self->{_query} = $q; } =head2 query() This method will return the cached WebService::MusicBrainz::Query object. =cut sub query { my $self = shift; return $self->{_query}; } =head2 search() This method will search the MusicBrainz database about track related information. The only argument is a hashref to define the search parameters. my $ws = WebService::MusicBrainz::Track->new(); $ws->search({ TITLE => 'when the stars go blue' }); $ws->search({ TITLE => 'blue', OFFSET => 100 }); $ws->search({ ARTIST => 'Ryan Adams', TITLE => 'when the stars go blue' }); $ws->search({ RELEASE => 'Gold', TITLE => 'when the stars go blue' }); $ws->search({ DURATION => 200000, TITLE => 'when the stars go blue' }); $ws->search({ TRACKNUM => 7, TITLE => 'when the stars go blue' }); $ws->search({ ARTISTID => 'c80f38a6-9980-485d-997c-5c1a9cbd0d64', TITLE => 'when the stars go blue' }); $ws->search({ RELEASEID => '433adbc2-382f-4f3a-9ce9-401f221f5b3b', TITLE => 'when the stars go blue' }); $ws->search({ LIMIT => 5, TITLE => 'when the stars go blue' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'artist' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'releases' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'puids' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'artist-rels' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'release-rels' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'track-rels' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'url-rels' }); Multiple INC params can be delimited by whitespace, commas, or + characters. $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'artist url-rels' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'artist,url-rels' }); $ws->search({ MBID => 'bd08eddf-b811-4653-b56b-892292c291bc', INC => 'artist+url-rels' }); =cut sub search { my $self = shift; my $params = shift; my $response = $self->query()->get('track', $params); return $response; } =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2007 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1; WebService-MusicBrainz-0.93/lib/WebService/MusicBrainz.pm0000444000175000017500000000332611304125306022616 0ustar bfaistbfaistpackage WebService::MusicBrainz; use strict; our $VERSION = '0.93'; =head1 NAME WebService::MusicBrainz =head1 SYNOPSIS use WebService::MusicBrainz; my $artist_ws = WebService::MusicBrainz->new_artist(); my $track_ws = WebService::MusicBrainz->new_track(); my $release_ws = WebService::MusicBrainz->new_release(); my $label_ws = WebService::MusicBrainz->new_label(); =head1 DESCRIPTION This module will act as a factory using static methods to return specific web service objects; =head1 METHODS =head2 new_artist() Return new instance of WebService::MusicBrainz::Artist object. =cut sub new_artist { my $class = shift; require WebService::MusicBrainz::Artist; return WebService::MusicBrainz::Artist->new(); } =head2 new_track Return new instance of WebService::MusicBrainz::Track object. =cut sub new_track { my $class = shift; require WebService::MusicBrainz::Track; return WebService::MusicBrainz::Track->new(); } =head2 new_release Return new instance of WebService::MusicBrainz::Release object. =cut sub new_release { my $class = shift; require WebService::MusicBrainz::Release; return WebService::MusicBrainz::Release->new(); } =head2 new_release Return new instance of WebService::MusicBrainz::Label object. =cut sub new_label { my $class = shift; require WebService::MusicBrainz::Label; return WebService::MusicBrainz::Label->new(); } =head1 AUTHOR =over 4 =item Bob Faist =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2007 by Bob Faist This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO http://wiki.musicbrainz.org/XMLWebService =cut 1;