Skip to content

Instantly share code, notes, and snippets.

@ox
Created September 9, 2011 15:18
Show Gist options
  • Save ox/1206492 to your computer and use it in GitHub Desktop.
Save ox/1206492 to your computer and use it in GitHub Desktop.
Grab the latest Electro-House from Console.fm and make a spotify playlist out of it. Fuck downloading. It's naive.
['open-uri', 'hpricot', 'meta-spotify'].each(&method(:require))
playlist = []
(open("http://console.fm/electro-house") { |html| Hpricot(html) }).search("a[@href*=media.console.fm/tracks]").each do |a|
m = a.inner_html.match(/(.*?) by (.*?)$/)
song = MetaSpotify::Track.search(m[1])[:tracks].first
unless song == nil
puts "\e[32m#{song.name} by #{song.artists.first.name}\e[0m, #{song.uri} "
playlist << song.uri
else
puts "\e[31mX\e[0m \"#{a.inner_html}\""
end
end
`echo \'#{playlist.join("\n")}\' | pbcopy`;
puts "copied #{playlist.size} songs"
puts "paste that into a spotify playlist. Jam out."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment