From 73de6bb8dfe9100767e9d6d0d4f0292da8eae76a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 26 May 2010 23:13:12 +0200 Subject: [PATCH] 20-lyricwiki.rb: recode recieved lyrics The lyrics are recieved in Latin1, but UTF-8 is needed. --- lyrics/20-lyricwiki.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lyrics/20-lyricwiki.rb b/lyrics/20-lyricwiki.rb index db7b970..3873e7a 100755 --- a/lyrics/20-lyricwiki.rb +++ b/lyrics/20-lyricwiki.rb @@ -24,6 +24,7 @@ require 'uri' require 'net/http' require 'cgi' +require 'iconv' url = "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong" + \ "&artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}" @@ -48,4 +49,6 @@ if not $1 =~ /^.*<\/div>(.*?)$/im exit(1) end -puts CGI::unescapeHTML($1.gsub(/
/, "\n")) +# lyrics come in Latin1, but we need UTF-8 +lyrics_latin1 = CGI::unescapeHTML($1.gsub(/
/, "\n")) +puts Iconv.conv('UTF-8//TRANSLIT//IGNORE', 'Latin1', lyrics_latin1) -- 2.30.2