Created
September 9, 2011 15:18
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
['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