commit
687ce1b785
|
@ -93,7 +93,8 @@ MusicBrainz::ReleaseGroup.search(artist_name, title, type: 'Album')
|
|||
:type => String,
|
||||
:title => String,
|
||||
:desc => String,
|
||||
:first_release_date => Date
|
||||
:first_release_date => Date,
|
||||
:urls => Hash
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ module MusicBrainz
|
|||
type: (xml.attribute('type').value rescue nil),
|
||||
title: (xml.xpath('./title').text rescue nil),
|
||||
desc: (xml.xpath('./disambiguation').text rescue nil),
|
||||
first_release_date: (xml.xpath('./first-release-date').text rescue nil)
|
||||
first_release_date: (xml.xpath('./first-release-date').text rescue nil),
|
||||
urls: (Hash[xml.xpath('./relation-list[@target-type="url"]/relation').map{ |xml|
|
||||
[xml.attribute('type').value.downcase.split(" ").join("_").to_sym, xml.xpath('./target').text]
|
||||
}] rescue {})
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module MusicBrainz
|
|||
field :urls, Hash
|
||||
|
||||
def release_groups
|
||||
@release_groups ||= client.load(:release_group, { artist: id }, {
|
||||
@release_groups ||= client.load(:release_group, { artist: id, inc: [:url_rels] }, {
|
||||
binding: :artist_release_groups,
|
||||
create_models: :release_group,
|
||||
sort: :first_release_date
|
||||
|
|
|
@ -5,6 +5,7 @@ module MusicBrainz
|
|||
field :title, String
|
||||
field :desc, String
|
||||
field :first_release_date, Date
|
||||
field :urls, Hash
|
||||
|
||||
alias_method :disambiguation, :desc
|
||||
|
||||
|
@ -18,7 +19,7 @@ module MusicBrainz
|
|||
|
||||
class << self
|
||||
def find(id)
|
||||
client.load(:release_group, { id: id }, {
|
||||
client.load(:release_group, { id: id, inc: [:url_rels] }, {
|
||||
binding: :release_group,
|
||||
create_model: :release_group
|
||||
})
|
||||
|
|
|
@ -56,5 +56,6 @@ describe MusicBrainz::Artist do
|
|||
release_groups.first.type.should == "Single"
|
||||
release_groups.first.title.should == "Club Foot"
|
||||
release_groups.first.first_release_date.should == Date.new(2004, 5, 10)
|
||||
release_groups.first.urls[:discogs].should == 'http://www.discogs.com/master/125150'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@ describe MusicBrainz::ReleaseGroup do
|
|||
release_group.type.should == "Album"
|
||||
release_group.title.should == "Empire"
|
||||
release_group.first_release_date.should == Date.new(2006, 8, 28)
|
||||
release_group.urls[:wikipedia].should == 'http://en.wikipedia.org/wiki/Empire_(Kasabian_album)'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue