Skip to content

Commit

Permalink
Merge pull request putpat#27 from krasnoukhov/library
Browse files Browse the repository at this point in the history
Added getArtists and getAlbums from Library
  • Loading branch information
bitboxer committed Nov 15, 2012
2 parents a56e080 + 31769cd commit ac634e3
Show file tree
Hide file tree
Showing 6 changed files with 1,359 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rockstar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
require 'rockstar/chart'
require 'rockstar/event'
require 'rockstar/geo'
require 'rockstar/library'
require 'rockstar/metro'
require 'rockstar/user'
require 'rockstar/tag'
Expand Down
13 changes: 13 additions & 0 deletions lib/rockstar/library.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Rockstar
class Library < Base

def artists(force=false, options = {})
get_instance("library.getArtists", :artists, :artist, options, force)
end

def albums(force=false, options = {})
get_instance("library.getAlbums", :albums, :album, options, force)
end

end
end
23 changes: 22 additions & 1 deletion lib/rockstar/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def load_profile
@avatar = @images["small"]
end

def top_artists(force=false, options = {} )
def top_artists(force=false, options = {})
default_options = {
:period => self.period
}
Expand Down Expand Up @@ -175,6 +175,27 @@ def weekly_track_chart(from=nil, to=nil)
(doc/:track).inject([]) { |elements, el| elements << Track.new_from_xml(el); elements }
end

# Wrappers for Rockstar::Library
def artists(force=false, options = {})
default_options = {
:user => @username
}
options = default_options.merge(options)

library = Rockstar::Library.new
library.artists(false, options)
end

def albums(force=false, options = {})
default_options = {
:user => @username
}
options = default_options.merge(options)

library = Rockstar::Library.new
library.albums(false, options)
end

# Get the recommendated events for the user, auth.session.key needed.
def events(session_key, force = false)
get_instance("user.getEvents", :events, :event, {:user => @username, :sk => session_key}, force)
Expand Down
Loading

0 comments on commit ac634e3

Please sign in to comment.