Skip to content

Instantly share code, notes, and snippets.

plugin do
def tinysong(title, artist)
response = Net::HTTP.new("tinysong.com").start do |h|
req = Net::HTTP::Get.new("?s=#{URI.escape "#{t.name} by #{t.artist}"}")
r.add_field("X-Requested-With", "XMLHttpRequest")
h.request(req)
end
response.body =~ %r{"(http:\\/\\/tinysong.com.+?)"} ? $1.gsub("\\", "") : nil
end