Class: ListenBrainz::Recording
- Defined in:
- lib/listenbrainz/models/recording.rb
Overview
Model class for recordings.
Defined Under Namespace
Classes: Payload
Instance Attribute Summary collapse
- #artist_mbids ⇒ Array<String> readonly
- #artist_name ⇒ String readonly
- #listen_count ⇒ Integer readonly
- #recording_mbid ⇒ String? (also: #mbid) readonly
- #release_mbid ⇒ String readonly
- #release_name ⇒ String readonly
- #track_name ⇒ String (also: #name) readonly
Class Method Summary collapse
-
.get(username = ListenBrainz.client.username, count: nil, offset: nil, range: nil) ⇒ Payload
Retrieves the top recordings for the given user.
-
.sitewide(count: nil, offset: nil, range: nil) ⇒ Payload
Retrieves the site-wide top recordings.
Methods inherited from Base
Instance Attribute Details
#artist_mbids ⇒ Array<String> (readonly)
73 |
# File 'lib/listenbrainz/models/recording.rb', line 73 attribute :artist_mbids, Types::Array.of(Types::String) |
#artist_name ⇒ String (readonly)
77 |
# File 'lib/listenbrainz/models/recording.rb', line 77 attribute :artist_name, Types::String |
#listen_count ⇒ Integer (readonly)
81 |
# File 'lib/listenbrainz/models/recording.rb', line 81 attribute :listen_count, Types::Integer |
#recording_mbid ⇒ String? (readonly) Also known as: mbid
85 |
# File 'lib/listenbrainz/models/recording.rb', line 85 attribute? :recording_mbid, Types::String.optional |
#release_mbid ⇒ String (readonly)
90 |
# File 'lib/listenbrainz/models/recording.rb', line 90 attribute? :release_mbid, Types::String.optional |
#release_name ⇒ String (readonly)
94 |
# File 'lib/listenbrainz/models/recording.rb', line 94 attribute :release_name, Types::String |
#track_name ⇒ String (readonly) Also known as: name
98 |
# File 'lib/listenbrainz/models/recording.rb', line 98 attribute :track_name, Types::String |
Class Method Details
.get(username = ListenBrainz.client.username, count: nil, offset: nil, range: nil) ⇒ Payload
Retrieves the top recordings for the given user.
18 19 20 21 22 23 24 25 26 |
# File 'lib/listenbrainz/models/recording.rb', line 18 def self.get( username = ListenBrainz.client.username, count: nil, offset: nil, range: nil ) params = { count:, offset:, range: }.compact ListenBrainz.client.query( :get, "1/stats/user/#{username}/recordings", params: ).fetch(:payload).then { Payload.new(_1) } end |
.sitewide(count: nil, offset: nil, range: nil) ⇒ Payload
Retrieves the site-wide top recordings.
38 39 40 41 42 |
# File 'lib/listenbrainz/models/recording.rb', line 38 def self.sitewide(count: nil, offset: nil, range: nil) params = { count:, offset:, range: }.compact ListenBrainz.client.query(:get, '1/stats/sitewide/recordings', params:) .fetch(:payload).then { Payload.new(_1) } end |