Floppy / tv_grab_uk_sky

XMLTV Grabber for the Sky online EPG
http://github.com/Floppy/tv_grab_uk_sky
8 stars 1 forks source link

malformed JSON string #3

Closed jmwislez closed 14 years ago

jmwislez commented 14 years ago

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?

jmwislez commented 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.

Floppy commented 14 years ago

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?

Floppy commented 14 years ago

Sorry, that's completely the wrong language, I'm used to thinking in Ruby :)

Just looking for how to do it in Perl...

Floppy commented 14 years ago

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'

jmwislez commented 14 years ago

It's actually UTF-8, but it works! Thanks a lot!

jmwislez commented 14 years ago

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.

Floppy commented 14 years ago

Great! Yes, if you have a patch, please put it in here and I will apply it to the code. Thanks!

jmwislez commented 14 years ago

--- /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.

jmwislez commented 14 years ago

Hmm, this formats strangely. Hope you can extract the patch. I can't find out how to submit it properly ...

Floppy commented 13 years ago

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.