2013-11-06 02:15:09 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2012-10-12 12:45:51 +00:00
|
|
|
module MusicBrainz
|
2013-01-20 12:36:52 +00:00
|
|
|
class Release < BaseModel
|
2012-10-12 12:45:51 +00:00
|
|
|
field :id, String
|
2013-01-24 20:12:58 +00:00
|
|
|
field :type, String
|
2012-10-12 12:45:51 +00:00
|
|
|
field :title, String
|
|
|
|
field :status, String
|
|
|
|
field :format, String
|
2013-01-20 12:36:52 +00:00
|
|
|
field :date, Date
|
2012-10-12 12:45:51 +00:00
|
|
|
field :country, String
|
2013-01-22 15:19:36 +00:00
|
|
|
field :asin, String
|
|
|
|
field :barcode, String
|
|
|
|
field :quality, String
|
2014-01-13 08:32:45 +00:00
|
|
|
|
2012-10-12 12:45:51 +00:00
|
|
|
def tracks
|
2013-01-20 12:36:52 +00:00
|
|
|
@tracks ||= client.load(:release, { id: id, inc: [:recordings, :media], limit: 100 }, {
|
|
|
|
binding: :release_tracks,
|
|
|
|
create_models: :track,
|
2012-10-12 12:45:51 +00:00
|
|
|
sort: :position
|
|
|
|
}) unless @id.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
class << self
|
|
|
|
def find(id)
|
2013-01-24 20:12:58 +00:00
|
|
|
client.load(:release, { id: id, inc: [:media, :release_groups] }, {
|
2013-01-20 12:36:52 +00:00
|
|
|
binding: :release,
|
|
|
|
create_model: :release
|
2012-10-12 12:45:51 +00:00
|
|
|
})
|
|
|
|
end
|
2014-01-13 08:32:45 +00:00
|
|
|
|
|
|
|
def find_by_discid(id)
|
2014-01-13 10:23:42 +00:00
|
|
|
client.load(:discid, { id: id }, {
|
|
|
|
binding: :discid_releases,
|
2014-01-13 08:32:45 +00:00
|
|
|
create_models: :release
|
|
|
|
})
|
|
|
|
end
|
2012-10-12 12:45:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|