summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 686b368)
raw | patch | inline | side by side (parent: 686b368)
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Mon, 8 Aug 2011 22:47:36 +0000 (00:47 +0200) | ||
committer | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Mon, 8 Aug 2011 22:47:36 +0000 (00:47 +0200) |
lyrics/20-lyricwiki.rb | patch | blob | history |
diff --git a/lyrics/20-lyricwiki.rb b/lyrics/20-lyricwiki.rb
index 3873e7a8120cec248817391c8cf8d8f0c8189623..87022492b95497a4659beb7f610190a02eba6610 100755 (executable)
--- a/lyrics/20-lyricwiki.rb
+++ b/lyrics/20-lyricwiki.rb
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 =~ /<url>\s*(.*?)\s*<\/url>/im