Class: Scrobbler::Library
Overview
TODO:
everything
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #add_album ⇒ Object
- #add_artist ⇒ Object
- #add_track ⇒ Object
-
#albums(options = {}) ⇒ Object
A list of all the albums in a user’s library, with play counts and tag counts.
-
#artists(options = {}) ⇒ Object
A list of all the artists in a user’s library, with play counts and tag counts.
-
#initialize(user) ⇒ Library
constructor
A new instance of Library.
-
#tracks(options = {}) ⇒ Object
A list of all the tracks in a user’s library, with play counts and tag counts.
Methods inherited from Base
api_key=, connection, get, maybe_streamable_attribute, maybe_streamable_node, post_request, request, sanitize, secret=
Constructor Details
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/scrobbler/library.rb', line 4 def user @user end |
Instance Method Details
#add_album ⇒ Object
11 12 13 14 |
# File 'lib/scrobbler/library.rb', line 11 def add_album # This function require authentication, but SimpleAuth is not yet 2.0 raise NotImplementedError end |
#add_artist ⇒ Object
16 17 18 19 |
# File 'lib/scrobbler/library.rb', line 16 def add_artist # This function require authentication, but SimpleAuth is not yet 2.0 raise NotImplementedError end |
#add_track ⇒ Object
21 22 23 24 |
# File 'lib/scrobbler/library.rb', line 21 def add_track # This function require authentication, but SimpleAuth is not yet 2.0 raise NotImplementedError end |
#albums(options = {}) ⇒ Object
A list of all the albums in a user’s library, with play counts and tag counts.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/scrobbler/library.rb', line 28 def albums(={}) = {:force => false, :all => true}.merge [:user] = @user.name albums = [] if [:all] doc = Base.request('library.getalbums', ) root = nil doc.root.children.each do |child| next unless child.name == 'albums' root = child end total_pages = root['totalPages'].to_i root.children.each do |child| next unless child.name == 'album' albums << Scrobbler::Album.new_from_libxml(child) end for i in 2..total_pages do [:page] = i albums.concat get_response('library.getalbums', :none, 'albums', 'album', , true) end else albums = get_response('library.getalbums', :get_albums, 'albums', 'album', , true) end albums end |
#artists(options = {}) ⇒ Object
A list of all the artists in a user’s library, with play counts and tag counts.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/scrobbler/library.rb', line 56 def artists(={}) = {:force => false, :all => true}.merge [:user] = @user.name artists = [] if [:all] doc = Base.request('library.getartists', ) root = nil doc.root.children.each do |child| next unless child.name == 'artists' root = child end total_pages = root['totalPages'].to_i root.children.each do |child| next unless child.name == 'artist' artists << Scrobbler::Artist.new_from_libxml(child) end for i in 2..total_pages do [:page] = i artists.concat get_response('library.getartists', :none, 'artists', 'artist', , true) end else artists = get_response('library.getartists', :get_albums, 'artists', 'artist', , true) end artists end |
#tracks(options = {}) ⇒ Object
A list of all the tracks in a user’s library, with play counts and tag counts.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/scrobbler/library.rb', line 84 def tracks(={}) = {:force => false, :all => true}.merge [:user] = @user.name tracks = [] if [:all] doc = Base.request('library.gettracks', ) root = nil doc.root.children.each do |child| next unless child.name == 'tracks' root = child end total_pages = root['totalPages'].to_i root.children.each do |child| next unless child.name == 'track' tracks << Scrobbler::Track.new_from_libxml(child) end for i in 2..total_pages do [:page] = i tracks.concat get_response('library.gettracks', :none, 'tracks', 'track', , true) end else tracks = get_response('library.gettracks', :get_albums, 'tracks', 'track', , true) end tracks end |