Code

updated lyricwiki plugin
authorThomas Jansen <mithi@mithi.net>
Wed, 9 Sep 2009 07:19:33 +0000 (09:19 +0200)
committerThomas 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.

lyrics/02-lyricwiki.rb

index 9c9f66378cd81e6dc74f03aa755586f42f436863..08938b82d0ead08db95a637748c859533c5bdbd4 100755 (executable)
@@ -30,4 +30,11 @@ response = Net::HTTP.get(URI.parse(url))
 
 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")