public
Description: Scrobbler is a wrapper for the audioscrobbler (last.fm) web services.
Homepage: http://scrobbler.rubyforge.org/
Clone URL: git://github.com/jnunemaker/scrobbler.git
Click here to lend your support to: scrobbler and make a donation at www.pledgie.com !
jnunemaker (author)
Thu Apr 30 05:01:14 -0700 2009
commit  a6096395bc686cedda9bcbc2420fbc12cd88f45a
tree    ff12f7e1aae7686d92fdba9e871f0a1f2708cd25
parent  df1c8a37d85ab0dce296839f43876792fe67b983
name age message
file .gitignore Wed Dec 03 08:53:15 -0800 2008 Added ignore file. [jnunemaker]
file History.txt Mon Apr 13 06:26:59 -0700 2009 Changed the way query string information gets e... [jnunemaker]
file MIT-LICENSE Mon Oct 22 21:00:36 -0700 2007 added mit license git-svn-id: http://svn.addi... [jnunemaker]
file Manifest Fri Dec 12 19:51:03 -0800 2008 tweaked Rakefile to exclude website from gem [Jonathan Rudenberg]
file README.rdoc Thu Apr 30 05:01:14 -0700 2009 updated readme with rdoc stuff. [jnunemaker]
file Rakefile Fri Dec 12 19:51:03 -0800 2008 tweaked Rakefile to exclude website from gem [Jonathan Rudenberg]
directory examples/ Mon Apr 13 06:26:59 -0700 2009 Changed the way query string information gets e... [jnunemaker]
directory lib/ Mon Apr 13 06:28:01 -0700 2009 Prepped for 0.2.3. [jnunemaker]
file scrobbler.gemspec Mon Apr 13 06:28:01 -0700 2009 Prepped for 0.2.3. [jnunemaker]
file setup.rb Thu May 10 07:14:23 -0700 2007 initial commit of scrobbler gem git-svn-id: h... [jnunemaker]
directory test/ Wed Dec 03 19:13:14 -0800 2008 refactored REST mock a bit [Jonathan Rudenberg]
directory website/ Wed Dec 03 10:06:29 -0800 2008 Tweaked deployment of website and docs. [jnunemaker]
README.rdoc

Scrobbler

Scrobbler is a wrapper for the audioscrobbler web services (www.audioscrobbler.net/data/webservices/).

Below is just a sampling of how easy this lib is to use.

Users

        user = Scrobbler::User.new('jnunemaker')

        puts "#{user.username}'s Recent Tracks"
        puts "=" * (user.username.length + 16)
        user.recent_tracks.each { |t| puts t.name }

        puts
        puts

        puts "#{user.username}'s Top Tracks"
        puts "=" * (user.username.length + 13)
        user.top_tracks.each { |t| puts "(#{t.playcount}) #{t.name}" }

Albums

        album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)

        puts "Album: #{album.name}"
        puts "Artist: #{album.artist}"
        puts "Reach: #{album.reach}"
        puts "URL: #{album.url}"
        puts "Release Date: #{album.release_date.strftime('%m/%d/%Y')}"

        puts
        puts

        puts "Tracks"
        longest_track_name = album.tracks.collect(&:name).sort { |x, y| y.length <=> x.length }.first.length
        puts "=" * longest_track_name
        album.tracks.each { |t| puts t.name }

Artists

        artist = Scrobbler::Artist.new('Carrie Underwood')

        puts 'Top Tracks'
        puts "=" * 10
        artist.top_tracks.each { |t| puts "(#{t.reach}) #{t.name}" }

        puts

        puts 'Similar Artists'
        puts "=" * 15
        artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }

Tags

        tag = Scrobbler::Tag.new('country')

        puts 'Top Albums'
        tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }

        puts

        puts 'Top Tracks'
        tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by #{t.artist}" }

Tracks

        track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
        puts 'Fans'
        puts "=" * 4
        track.fans.each { |u| puts "(#{u.weight}) #{u.username}" }

Simple Authentication (for Scrobbling)

    auth = Scrobbler::SimpleAuth.new(:user => 'chunky', :password => 'bacon')
    auth.handshake!

    puts "Auth Status: #{auth.status}"
    puts "Session ID: #{auth.session_id}"
    puts "Now Playing URL: #{auth.now_playing_url}"
    puts "Submission URL: #{auth.submission_url}"

Scrobbling

    scrobble = Scrobbler::Scrobble.new(:session_id => auth.session_id,
                                       :submission_url => auth.submission_url,
                                       :artist => 'Coldplay',
                                       :track => 'Viva La Vida',
                                       :album => "Viva La Vida",
                                       :time => Time.new,
                                       :length => 244,
                                       :track_number => 7)
    scrobble.submit!
    puts "Scrobbler Submission Status: #{scrobble.status}"

Now Playing Submission

    playing = Scrobbler::Playing.new(:session_id => auth.session_id,
                                     :now_playing_url => auth.now_playing_url,
                                     :artist => 'Anberlin',
                                     :track => 'Readyfuels',
                                     :album => 'Blueprints For the Black Market',
                                     :length => 218,
                                     :track_number => 1)

    playing.submit!
    puts "Playing Submission Status: #{playing.status}"

Docs

rdoc.info/projects/jnunemaker/scrobbler