Merge remote-tracking branch 'danbee/feature/find-release-by-discid' into feature/find-release-by-discid
This commit is contained in:
commit
33e280ec2c
|
@ -24,6 +24,7 @@ require "musicbrainz/models/track"
|
|||
require "musicbrainz/bindings/artist"
|
||||
require "musicbrainz/bindings/artist_search"
|
||||
require "musicbrainz/bindings/artist_release_groups"
|
||||
require "musicbrainz/bindings/discid_releases"
|
||||
require "musicbrainz/bindings/relations"
|
||||
require "musicbrainz/bindings/release_group"
|
||||
require "musicbrainz/bindings/release_group_search"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
module MusicBrainz
|
||||
module Bindings
|
||||
module DiscidReleases
|
||||
def parse(xml)
|
||||
xml.xpath('./disc/release-list/release').map do |xml|
|
||||
MusicBrainz::Bindings::Release.parse(xml)
|
||||
end
|
||||
end
|
||||
|
||||
extend self
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@ module MusicBrainz
|
|||
field :asin, String
|
||||
field :barcode, String
|
||||
field :quality, String
|
||||
|
||||
|
||||
def tracks
|
||||
@tracks ||= client.load(:release, { id: id, inc: [:recordings, :media], limit: 100 }, {
|
||||
binding: :release_tracks,
|
||||
|
@ -26,6 +26,13 @@ module MusicBrainz
|
|||
create_model: :release
|
||||
})
|
||||
end
|
||||
|
||||
def find_by_discid(id)
|
||||
client.load(:discid, { id: id }, {
|
||||
binding: :discid_releases,
|
||||
create_models: :release
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,4 +35,12 @@ describe MusicBrainz::Release do
|
|||
expect(tracks.first.title).to eq "Empire"
|
||||
expect(tracks.first.length).to eq 233013
|
||||
end
|
||||
|
||||
it "gets a list of matching releases for a discid" do
|
||||
releases = MusicBrainz::Release.find_by_discid("pmzhT6ZlFiwSRCdVwV0eqire5_Y-")
|
||||
releases.length.should == 2
|
||||
releases.first.id.should == "7a31cd5f-6a57-4fca-a731-c521df1d3b78"
|
||||
releases.first.title.should == "Kveikur"
|
||||
releases.first.asin.should == "B00C1GBOU6"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue