aboutsummaryrefslogtreecommitdiffstats
path: root/lyrics/lyricswiki.rb
blob: 39aa4a5b7469ac9097236e4e6a9ff28db4c9fc7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env ruby
#
# Load lyrics from lyricswiki.org
#
# Author: Max Kellermann <max@duempel.org>
#

require 'uri'
require 'net/http'

url = "http://lyricwiki.org/api.php" + \
    "?artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}"
response = Net::HTTP.get(URI.parse(url))

exit(2) unless response =~ /<pre>\s*(.*?)\s*<\/pre>/im
puts $1