From: Thomas Jansen Date: Sat, 12 Sep 2009 22:29:28 +0000 (+0200) Subject: update lyricwiki plugin to lyric.wikia.com X-Git-Tag: release-0.15~21 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8e77d8c50bd1dda0deb0104d99f26e504b9dd6df;p=ncmpc.git update lyricwiki plugin to lyric.wikia.com Lyricwiki was integrated into wikia.com. This changed the URL and once again the API. --- 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*