diff --git a/lyrics/20-lyricwiki.rb b/lyrics/20-lyricwiki.rb
index 9ab72b826722fe74d023ef361ffc11a580ae43ee..fde22e44a835144efddc0fd7dfa55fe039a2497c 100755 (executable)
--- a/lyrics/20-lyricwiki.rb
+++ b/lyrics/20-lyricwiki.rb
#!/usr/bin/env ruby
#
-# (c) 2004-2008 The Music Player Daemon Project
+# (c) 2004-2017 The Music Player Daemon Project
# http://www.musicpd.org/
#
# This program is free software; you can redistribute it and/or modify
#
require 'uri'
-require 'net/http'
+require 'open-uri'
require 'cgi'
# We need this because URI.escape doesn't escape ampersands.
url = "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong" + \
"&artist=#{escape(ARGV[0])}&song=#{escape(ARGV[1])}"
-response = Net::HTTP.get(URI.parse(url))
+response = open(URI.parse(url)).read
if not response =~ /<url>\s*(.*?)\s*<\/url>/im
$stderr.puts "No URL in response!"
url = $1
exit(69) if url =~ /action=edit$/
-response = Net::HTTP.get(URI.parse(url))
-if not response =~ /<div class='lyricbox'>\s*(.*?)\s*<!--/im
+response = open(URI.parse(url)).read
+if not response =~ /<div class='lyricbox'>\s*(.*?)\s*<div class='lyricsbreak'>/im
$stderr.puts "No <div class='lyricbox'> in lyrics page!\n"
exit(1)
end
-if not $1 =~ /^.*<\/script>(.*?)$/im
- $stderr.puts "Couldn't remove leading XML tags in lyricbox!\n"
- exit(1)
-end
-
lyrics = $1.gsub(/<br \/>/, "\n")
if lyrics.respond_to?(:force_encoding)