Closed jmwislez closed 14 years ago
Solved after I found on a forum that one needs to search and replace www.sky.com/portletepg with epgservices.sky.com/tvlistings-proxy
But now I bump into the next problem: malformed UTF-8 character in JSON string, at character offset 17142 (before "\x{9b6f}i movies","c...") at /usr/local/bin/tv_grab_uk_sky line 205.
Hm, interesting - looks like they've changed the URL, and might be using UTF-16 encoding. Does changing JSON.parse(...) to JSON.parse(..., "UTF-16") make any difference?
Sorry, that's completely the wrong language, I'm used to thinking in Ruby :)
Just looking for how to do it in Perl...
Looks like it should be something like this instead of decode_json():
use Encode; $object = JSON::XS->new->decode (decode "UTF-16BE", $jsontext);
Found at http://search.cpan.org/~makamaka/JSON-2.21/lib/JSON.pm in section 'utf8'
It's actually UTF-8, but it works! Thanks a lot!
Maybe I shouldn't have closed this issue as long as the downloadable code is not on. If you want I can provide it by mail.
Great! Yes, if you have a patch, please put it in here and I will apply it to the code. Thanks!
--- /home/jmw/tv_grab_uk_sky.orig 2010-07-16 19:37:29.000000000 +0200 +++ /usr/local/bin/tv_grab_uk_sky 2010-07-15 12:46:36.000000000 +0200 @@ -73,6 +73,7 @@ use JSON; use HTML::Entities; use DateTime; +use Encode;
my( $opt, $conf ) = ParseOptions( { grabber_name => "tv_grab_uk_sky", @@ -104,12 +105,12 @@ my $timestr = $time->strftime("%Y%m%d%H%M"); # Time and date in YYYYMMDDhhmm format my $dur = $last_day - $grab_offset < 2 ? 1440 : 2880; # Length of data to fetch in minutes (2880 max - 2 days) my $detail = 2; # 2 gives full epg data with descriptions, any other number gives no desc.
my $channel_data = JSON::XS->new->decode (decode "UTF-8", $res);
# Store channel information
foreach my $x ($channeldata->{channels})
{
@@ -200,9 +201,9 @@
my( $conf, $opt ) = @;
my $channel_list = '<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE tv SYSTEM "xmltv.dtd">
# Load http://www.sky.com/portletepg/TVListingsProxy/init.json and convert to XML channel list
my $channel_data = JSON::XS->new->decode (decode "UTF-8", $res);
foreach my $channel (@{$channel_data->{channels}}) {
Hmm, this formats strangely. Hope you can extract the patch. I can't find out how to submit it properly ...
I've finally got around to applying this patch. Sorry it took so long! I can't test it locally (no XMLTV setup any more), so let me know if you have any problems.
when running the grabber I get:
malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at ./tv_grab_uk_sky_2 line 205.
Any clue?