
WWW::Discogs - get music related information and images

Interface with www.discogs.com API to get music related information and images. Discogs is a user-built database containing information on artists, labels, and their recordings.

use WWW::Discogs;
my $client = WWW::Discogs->new;
# --
# print all vinyl (12") releases from label 'Drumcode'
# --
my $label = $client->label(name => 'Drumcode', releases => 1);
my @vinyls = grep { $_->{format} =~ /12\"/ } $label->releases;
for my $rel (@vinyls) {
print join("\t",
$rel->{catno},
$rel->{artist},
$rel->{title},
$rel->{format},
);
print "\n";
}
# --
# print all covers for records by Nima Khak
# --
my @all_rels = $client->artist(name => 'Nima Khak', releases => 1)->releases;
my @main_rels = grep { $_->{role} eq 'Main' } @all_rels;
RELEASE:
for my $r (@main_rels) {
my $release;
if ($r->{type} eq 'master') {
my $master = $client->master(id => $r->{id});
$release = $client->release(id => $master->main_release);
}
elsif ($r->{type} eq 'release') {
$release = $client->release(id => $r->{id});
}
my @images = $release->images(type => 'primary');
next RELEASE unless scalar(@images);
print join("\t", $release->title, $images[0]->{uri}), "\n";
}

Returns a WWW::Discogs::Search object. If you want to narrow down search results then provide $search_type which can be one of 'all' (the default), 'releases' (also returns masters), 'artists' or 'labels'. Search results are paginated (20 results per page) and default is page => 1. You can check how many search results pages are there by calling pages method on WWW::Discogs::Search object.
Returns a WWW::Discogs::Release object. You can get a $release_id from a search, artist, or label.
Returns a WWW::Discogs::Master object. You can get a $master_id from a search or release.
Returns a WWW::Discogs::Artist object. You can get the exact name of an artist from a search result's title.
Returns a WWW::Discogs::Label object. You can get the exact name of a label from a search result's title.

Returns list of hash references containing results exactly matching search query. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $search = $client->search(q => 'adam beyer');
for my $result ($search->exactresults) {
print join(" - ", $result->{type}, $result->{title}, $result->{uri});
print "\n";
}
Returns list of hash references containing search results.
Returns a number of search results (counted without exact results).
Returns number of search results' pages. Each page contains max 20 search results.
Returns release ID.
Returns title of the release.
Returns a list of hash references containing information about images for a release. $image_type can be one of 'primary' or 'secondary'. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $release = $client->release(id => 797674);
for my $img ( $release->images(type => 'primary') ) {
print join(" - ",
$img->{width}, $img->{height}, $img->{uri},
$img->{uri150}, $img->{type},
);
print "\n";
}
Returns release date in ISO 8601 format (YYYY-MM-DD).
Returns formatted release date ('06 Oct 2006', 'Mar 2006' etc.)
Returns a list of hash references containing labels information. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $release = $client->release(id => 797674);
for my $label ($release->labels) {
print join(" - ", $label->{name}, $label->{catno});
}
Returns country.
Returns a list of hash references containing formats information. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $release = $client->release(id => 797674);
for my $format ($release->formats) {
printf("%d x %s, %s\n",
$format->{qty},
$format->{name},
join(", ", @{ $format->{descriptions } }),
);
}
Prints:
1 x CD, Album, Partially Mixed 1 x CD, Compilation, Limited Edition
Returns status.
Returns master release ID associated with a release.
Returns release year.
Returns release notes.
Returns a list of styles.
Returns a list of genres.
Returns a list of hash references containing artists information.
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $release = $client->release(id => 18618);
for my $artist ($release->artists) {
print join(" - ", $artist->{name}, $artist->{anv}, $artist->{role});
print "\n";
}
Returns a list of hash references containing extra artists information.
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $release = $client->release(id => 18618);
for my $exart ($release->extraartists) {
print join(" - ", $exart->{name}, $exart->{anv}, $exart->{role});
print "\n";
}
Returns tracklist as a list containing hash references. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $release = $client->release(id => 830189);
my @tracklist = $release->tracklist;
for my $track (sort { $a->{position} <=> $b->{position} } @tracklist) {
printf("%d. %s (%s)\n",
$track->{position}, $track->{title}, $track->{duration},
);
}
Returns master ID.
Returns main release ID.
Returns a list of hash references containing versions information. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $master = $client->master(id => 104330);
for my $version ( $master->versions ) {
printf("%9d %7s %15s %18s %7s %15s\n",
$version->{id}, $version->{country}, $version->{title},
$version->{format}, $version->{catno}, $version->{label});
}
Prints:
116934 Sweden Chaos & Order CD, Album HPCD20 H. Productions
11168 Sweden Chaos & Order 2xLP, Album HPLP20 H. Productions
2307050 Sweden Chaos & Order 2xLP, Album, W/Lbl HPLP20 H. Productions
Other available keys in $version besides the ones in example above are $version->{status} and $version->{released}.
Returns a list of hash references containing information about images for a release. $image_type can be one of 'primary' or 'secondary'. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $master = $client->master(id => 23992);
for my $img ( $master->images(type => 'secondary') ) {
print join(" - ",
$img->{width}, $img->{height}, $img->{uri},
$img->{uri150}, $img->{type},
);
print "\n";
}
Returns release year.
Returns release notes.
Returns a list of styles.
Returns a list of genres.
Returns a list of hash references containing artists information. See $release->artists for an example.
Returns a list of hash references containing extra artists information. See $release->extraartists for an example.
Returns tracklist. See $release->tracklist for an example.
Returns artist name.
Returns artist's real name
Returns a list of aliases used by the artist.
Returns a list of name variations for the artist.
Returns artist's profile information.
Returns a list of site's URLs linked to the artist.
Returns a list of hash references containing images information. See $release->images for an example.
If $client->artist method creating a new WWW::Discogs::Artist object was called with releases => 1 parameter you can get the list of artist's releases by calling this method. The result will be a list of hash references containing releases/master releases information. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $artist = $client->artist(name => "Adam Beyer", releases => 1);
foreach my $r ($artist->releases) {
printf("%8d %7s %17s %s\n", $r->{id}, $r->{type}, $r->{role}, $r->{title});
}
$r->{id} will contain release/master release ID$r->{type} will contain release type ('release' or 'master')$r->{role} will contain artist's role in release ('Main', 'Remix', 'Producer', 'Appearance', 'TrackAppearance' etc.)$r->{title} will contain release/master release titleFor releases with 'master' type you can get main release ID by checking the value of $r->{main_release}. Use Data::Dumper to find out more about this structure as results differ depending on artist's role and release type.
Returns label's name.
If $client->label method creating a new WWW::Discogs::Label object was called with releases => 1 parameter you can get the list of label's releases by calling this method. The result will be a list of hash references containing releases information. See example below:
use WWW::Discogs;
my $client = WWW::Discogs->new;
my $label = $client->label(name => 'Southsoul Appendix', releases => 1);
for my $r ($label->releases) {
print join("\t", $r->{id}, $r->{catno}, $r->{artist},
$r->{title}, $r->{format}
);
print "\n";
}
Returns contact info to the label.
Returns a list containing names of sublabels.
Returns the name of parent label.
Returns a list of hash references containing images information. See $release->images for an example.

0.11+: Michal Gasek <michal@gasek.eu>
0.01-0.10: Lee Aylward <lee@laylward.com>

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.