From 8e77d8c50bd1dda0deb0104d99f26e504b9dd6df Mon Sep 17 00:00:00 2001 From: Thomas Jansen Date: Sun, 13 Sep 2009 00:29:28 +0200 Subject: [PATCH] update lyricwiki plugin to lyric.wikia.com Lyricwiki was integrated into wikia.com. This changed the URL and once again the API. --- lyrics/02-lyricwiki.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lyrics/02-lyricwiki.rb b/lyrics/02-lyricwiki.rb index 08938b8..74c13b2 100755 --- a/lyrics/02-lyricwiki.rb +++ b/lyrics/02-lyricwiki.rb @@ -18,23 +18,21 @@ # # -# Load lyrics from lyricwiki.org +# Load lyrics from lyrics.wikia.com, formerly lyricwiki.org # require 'uri' require 'net/http' -url = "http://lyricwiki.org/api.php" + \ - "?artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}" +url = "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong" + \ + "&artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}" response = Net::HTTP.get(URI.parse(url)) -exit(2) unless response =~ /
\s*(.*?)\s*<\/pre>/im
-exit(2) if $1 == "Not found"
-
-url = $1
-url =~ //im
+exit(2) unless response =~ /\s*(.*?)\s*<\/url>/im
+url = $1.gsub(/wikia.com/, "wikia.com/lyrics");
+exit(2) if $1 =~ /action=edit$/
 
 response = Net::HTTP.get(URI.parse(url))
-exit(2) unless response =~ /
\s*(.*?)\s*

/im +exit(2) unless response =~ /

\s*(.*?)\s*