Skip to main content
Topic: Stream info not decoded from Unicode (Read 575 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Stream info not decoded from Unicode

Hi!
There is one Russian radio that can be listened to, but artist and song info are displayed as a part of JSON response.
http://ic2.101.ru:8000/a38
When I click "Copy Name" this is put into clipboard. Is there a chance to fix this?
Thanks!

{"t":"\u0425\u041e\u0420 \u041f\u0410\u0422\u0420\u0418\u0410\u0420\u0428\u0415\u0413\u041e \u041f\u041e\u0414\u0412\u041e\u0420\u042c\u042f \u0425\u0420\u0410\u041c\u0410 \u0412\u041e\u0421\u041a\u0420\u0415\u0421\u0415\u041d\u0418\u042f \u0425\u0420\u0418\u0421\u0422\u041e\u0412\u0410 \u041d\u0410 \u0421\u0415\u041c\u0415\u041d\u041e\u0412\u0421\u041a\u041e\u0419 - \u041d\u0435 \u041e\u0442\u0432\u0440\u0430\u0442\u0438 \u041b\u0438\u0446\u0430 \u0422\u0432\u043e\u0435\u0433\u043e","tT":"\u041d\u0435 \u041e\u0442\u0432\u0440\u0430\u0442\u0438 \u041b\u0438\u0446\u0430 \u0422\u0432\u043e\u0435\u0433\u043e","uT":350193,"tE":"\u0425\u041e\u0420 \u041f\u0410\u0422\u0420\u0418\u0410\u0420\u0428\u0415\u0413\u041e \u041f\u041e\u0414\u0412\u041e\u0420\u042c\u042f \u0425\u0420\u0410\u041c\u0410 \u0412\u041e\u0421\u041a\u0420\u0415\u0421\u0415\u041d\u0418\u042f \u0425\u0420\u0418\u0421\u0422\u041e\u0412\u0410 \u041d\u0410 \u0421\u0415\u041c\u0415\u041d\u041e\u0412\u0421\u041a\u041e\u0419","uTr":350193,"uE":50556,"tM":0,"eM":"0","cE":false,"c":false,"iU":false,"iP":false,"d":"335","l":"335","m":"mdb","lAU":1,"lAuU":18}

Re: Stream info not decoded from Unicode

Reply #1
Your stream appears to be sending a title encoded as JSON. There is no ShoutCast or IceCast equivalent that says you should expect that.

Re: Stream info not decoded from Unicode

Reply #2
Those \u0425 and the likes are indeed unicode values for the characters of that stream. The first five chars are: "ХОРПА".
You can translate character by character using the "characters map" application that comes with windows (on linux I've seen a similar one too).
html can decode unicode, but needs to be written using decimal encoding, while in this JSON it uses hexadecimal encoding, so it's not a quick solution.

One not-so-easy-but-not-too-hard solution is to write that as text as-is into a java file that prints it to console and then build it. But if you are at that point, you can make an application that reads the json and outputs into a .txt file.

There might be a way to make a small script with powershell or bash, but a quick search didn't give me the desired results.

Re: Stream info not decoded from Unicode

Reply #3
For a limited character set (only Russian), you could write a $replace script in Foobar. Problem is you'd have to copy it everywhere you need the titles: playlist, title bar, copy name, and adapt it if the Json changes format.

Start lists all the replacements, the fallback title format is at the end.

Code: [Select]
$puts(repl,$replace(%title%,\u0410,$char(1040),\u0411,$char(1041),\u0412,$char(1042),\u0413,$char(1043),\u0414,$char(1044),\u0415,$char(1045),\u0416,$char(1046),\u0417,$char(1047),\u0418,$char(1048),\u0419,$char(1049),\u041a,$char(1050),\u041b,$char(1051),\u041c,$char(1052),\u041d,$char(1053),\u041e,$char(1054),\u041f,$char(1055),\u0420,$char(1056),\u0421,$char(1057),\u0422,$char(1058),\u0423,$char(1059),\u0424,$char(1060),\u0425,$char(1061),\u0426,$char(1062),\u0427,$char(1063),\u0428,$char(1064),\u0429,$char(1065),\u042a,$char(1066),\u042b,$char(1067),\u042c,$char(1068),\u042d,$char(1069),\u042e,$char(1070),\u042f,$char(1071),\u0430,$char(1072),\u0431,$char(1073),\u0432,$char(1074),\u0433,$char(1075),\u0434,$char(1076),\u0435,$char(1077),\u0436,$char(1078),\u0437,$char(1079),\u0438,$char(1080),\u0439,$char(1081),\u043a,$char(1082),\u043b,$char(1083),\u043c,$char(1084),\u043d,$char(1085),\u043e,$char(1086),\u043f,$char(1087),\u0440,$char(1088),\u0441,$char(1089),\u0442,$char(1090),\u0443,$char(1091),\u0444,$char(1092),\u0445,$char(1093),\u0446,$char(1094),\u0447,$char(1095),\u0448,$char(1096),\u0449,$char(1097),\u044a,$char(1098),\u044b,$char(1099),\u044c,$char(1100),\u044d,$char(1101),\u044e,$char(1102),\u044f,$char(1103)))$puts(rper,$puts(temp,$substr($get(repl),$add($strstr($get(repl),'"tE":"'),6),999))$substr($get(temp),1,$sub($strstr($get(temp),'","'),1)))$puts(rtit,$puts(temp,$substr($get(repl),$add($strstr($get(repl),'"tT":"'),6),999))$substr($get(temp),1,$sub($strstr($get(temp),'","'),1)))$iflonger($get(rper)$get(rtit),0,$get(rper) - $get(rtit),%title%[ <<'//'>> %track artist%])

 

Re: Stream info not decoded from Unicode

Reply #4
You're welcome to resort to that, but know that there's a standard way to decode that format. It's just that the player doesn't expect that format to be used for this information.

Shoutcast, and by extension, Icecast, expect to send plaintext metadata in two possible strings to the player, on track changes. It does not specify that this data should be encoded as a JSON block, therefore it's rather unexpected.

 
SimplePortal 1.0.0 RC1 © 2008-2019