Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created June 28, 2010 21:51
Show Gist options
  • Save jhsu/456408 to your computer and use it in GitHub Desktop.
Save jhsu/456408 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'rss'
sources = %w(
http://ws.audioscrobbler.com/2.0/user/jhsu/lovedtracks.rss
http://ws.audioscrobbler.com/1.0/user/jhsu/recenttracks.rss
)
youtube_search = "http://www.youtube.com/results?search_query="
songs = sources.map {|source|
rss = open(source).read
result = RSS::Parser.parse(rss)
result.items
}.flatten
song = songs.shuffle.first
puts "#{song.title} (#{song.link}) (#{youtube_search}#{song.title.strip.gsub(/(\W|_)+/, '+').gsub(/\+$/, '')})"
# => Miike Snow _ Burial (http://www.last.fm/music/Miike+Snow/_/Burial) (http://www.youtube.com/results?search_query=Miike+Snow+Burial)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment