summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 23c27e8)
raw | patch | inline | side by side (parent: 23c27e8)
author | Lazaros Koromilas <lostd@2f30.org> | |
Sun, 12 Jun 2016 18:55:45 +0000 (20:55 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 13 Jun 2016 13:46:25 +0000 (15:46 +0200) |
NEWS | patch | blob | history | |
lyrics/20-lyricwiki.rb | patch | blob | history |
index 6db0158fe4b1cb14d9a4562bb7854fbd73049c58..2fb18600b4bb876a2e5ea6bb56615293ec447dd7 100644 (file)
--- a/NEWS
+++ b/NEWS
ncmpc 0.25 - not yet released
+* lyricswiki: handle redirects
ncmpc 0.24 - (2014-07-14)
diff --git a/lyrics/20-lyricwiki.rb b/lyrics/20-lyricwiki.rb
index 9ab72b826722fe74d023ef361ffc11a580ae43ee..3e284ff9e532e48552f306e3e0bfdfcc036f9cb1 100755 (executable)
--- a/lyrics/20-lyricwiki.rb
+++ b/lyrics/20-lyricwiki.rb
#
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))
+response = open(URI.parse(url)).read
if not response =~ /<div class='lyricbox'>\s*(.*?)\s*<!--/im
$stderr.puts "No <div class='lyricbox'> in lyrics page!\n"
exit(1)