=Scrobbler

Scrobbler is a wrapper for the audioscrobbler web services (http://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 "#useruser.username's Recent Tracks"
puts "=" * (user.username.length + 16)
user.recent_tracks.each { |t| puts t.name }

puts
puts

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

== Albums

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

puts "Album: #albumalbum.name"
puts "Artist: #albumalbum.artist"
puts "Reach: #albumalbum.reach"
puts "URL: #albumalbum.url"
puts "Release Date: #albumalbum.release_datealbum.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 "(#tt.reach) #tt.name" }

puts

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

==Tags

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

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

puts

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

==Tracks

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

== Simple Authentication (for Scrobbling)

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

puts "Auth Status: #authauth.status"
puts "Session ID: #authauth.session_id"
puts "Now Playing URL: #authauth.now_playing_url"
puts "Submission URL: #authauth.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: #scrobblescrobble.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: #playingplaying.status"