Skip to content

Instantly share code, notes, and snippets.

@shayne
Created December 6, 2009 21:38
Show Gist options
  • Save shayne/250436 to your computer and use it in GitHub Desktop.
Save shayne/250436 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
station_id = 'ea1cf660a072089e6d1a8c963c4de754ce73ab3d53acab5f'
songs = []
['track', 'thumb_up'].each do |s|
doc = Nokogiri::HTML(open("http://www.pandora.com/favorites/station_tablerows_#{s}.vm?token=#{station_id}"))
doc.css('tr').each do |row|
track = row.at_css('.track_title')[:tracktitle]
artist = row.at_css("a[@title='Artist details']").text
songs.push({:artist => artist, :track => track}) if artist && track
end
end
songs = songs.sort_by {|key| key[:artist]}
puts songs.to_yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment