Code

lyricwiki plugin: updated to their latest layout
authorThomas Jansen <mithi@mithi.net>
Sat, 3 Oct 2009 18:09:25 +0000 (20:09 +0200)
committerThomas Jansen <mithi@mithi.net>
Sat, 3 Oct 2009 18:09:25 +0000 (20:09 +0200)
lyrics/02-lyricwiki.rb

index 2e1aed79a6a639d2febfb3ae0396917fd8ae4463..b3b702825a4414f67f8c067b77d8d033bdaf06cb 100755 (executable)
@@ -33,8 +33,8 @@ if not response =~ /<url>\s*(.*?)\s*<\/url>/im
        exit(1)
 end
 
-url = $1.gsub(/wikia.com/, "wikia.com/lyrics");
-exit(69) if $1 =~ /action=edit$/
+url = $1
+exit(69) if url =~ /action=edit$/
 
 response = Net::HTTP.get(URI.parse(url))
 if not response =~ /<div class='lyricbox'>\s*(.*?)\s*<!--/im
@@ -42,4 +42,9 @@ if not response =~ /<div class='lyricbox'>\s*(.*?)\s*<!--/im
        exit(1)
 end
 
+if not $1 =~ /^.*<\/div>(.*?)$/im
+       $stderr.puts "Couldn't remove leading XML tags in lyricbox!\n"
+       exit(1)
+end
+
 puts $1.gsub(/<br \/>/, "\n")