summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ccc1fff)
raw | patch | inline | side by side (parent: ccc1fff)
author | Thomas Jansen <mithi@mithi.net> | |
Wed, 9 Sep 2009 07:19:33 +0000 (09:19 +0200) | ||
committer | Thomas Jansen <mithi@mithi.net> | |
Wed, 9 Sep 2009 09:58:54 +0000 (11:58 +0200) |
Lyricwiki doesn't provide lyrics directly through it's API anymore. Instead, a
link to the lyrics is returned if they were found. Follow that link to get the
real thing.
link to the lyrics is returned if they were found. Follow that link to get the
real thing.
lyrics/02-lyricwiki.rb | patch | blob | history |
diff --git a/lyrics/02-lyricwiki.rb b/lyrics/02-lyricwiki.rb
index 9c9f66378cd81e6dc74f03aa755586f42f436863..08938b82d0ead08db95a637748c859533c5bdbd4 100755 (executable)
--- a/lyrics/02-lyricwiki.rb
+++ b/lyrics/02-lyricwiki.rb
exit(2) unless response =~ /<pre>\s*(.*?)\s*<\/pre>/im
exit(2) if $1 == "Not found"
-puts $1
+
+url = $1
+url =~ /<a href='\s*(.*?)\s*'>/im
+
+response = Net::HTTP.get(URI.parse(url))
+exit(2) unless response =~ /<div class='lyricbox' >\s*(.*?)\s*<p>/im
+
+puts $1.gsub(/<br \/>/, "\n")