From: Jonathan Neuschäfer Date: Mon, 8 Aug 2011 22:47:36 +0000 (+0200) Subject: lyricwiki: allow ampersands in artist/song names X-Git-Tag: release-0.20~104 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1fe80920a99cb98e138fdbd64826915b44774d41;p=ncmpc.git lyricwiki: allow ampersands in artist/song names --- diff --git a/lyrics/20-lyricwiki.rb b/lyrics/20-lyricwiki.rb index 3873e7a..8702249 100755 --- a/lyrics/20-lyricwiki.rb +++ b/lyrics/20-lyricwiki.rb @@ -26,8 +26,14 @@ require 'net/http' require 'cgi' require 'iconv' +# We need this because URI.escape doesn't escape ampersands. +def escape(string) + new = URI.escape(string) + new.gsub(/&/, "%26") +end + url = "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong" + \ - "&artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}" + "&artist=#{escape(ARGV[0])}&song=#{escape(ARGV[1])}" response = Net::HTTP.get(URI.parse(url)) if not response =~ /\s*(.*?)\s*<\/url>/im