From 1fe80920a99cb98e138fdbd64826915b44774d41 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Tue, 9 Aug 2011 00:47:36 +0200 Subject: [PATCH] lyricwiki: allow ampersands in artist/song names --- lyrics/20-lyricwiki.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.30.2