From: Jonathan Neuschäfer Date: Wed, 26 May 2010 21:13:12 +0000 (+0200) Subject: 20-lyricwiki.rb: recode recieved lyrics X-Git-Tag: release-0.17~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=73de6bb8dfe9100767e9d6d0d4f0292da8eae76a;p=ncmpc.git 20-lyricwiki.rb: recode recieved lyrics The lyrics are recieved in Latin1, but UTF-8 is needed. --- 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)