From 7c11a5fad703aa671a80a6d3ecd0c51b9210cde0 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 11 May 2016 15:39:11 +0200 Subject: moved to JSON::MaybeXS diff --git a/debian/control b/debian/control index 2a62cdb..4e46118 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.9.5 Package: rhautoimport Architecture: all -Depends: ${misc:Depends}, adduser, libdate-calc-perl, libfile-slurp-perl, libjson-any-perl, librhrd-perl, liburi-perl, libwww-perl, libxml-feed-perl, perl, bsd-mailx +Depends: ${misc:Depends}, adduser, libdate-calc-perl, libfile-slurp-perl, libjson-maybexs-perl, librhrd-perl, liburi-perl, libwww-perl, libxml-feed-perl, perl, bsd-mailx Description: Radio Helsinki automatic importer This a set of scripts to automagically import shows from various external sources. diff --git a/depends b/depends deleted file mode 100644 index c0e7297..0000000 --- a/depends +++ /dev/null @@ -1,9 +0,0 @@ -libdate-calc-perl -libfile-slurp-perl -libjson-any-perl -librhrd-perl -liburi-perl -libwww-perl -libxml-feed-perl -perl -bsd-mailx diff --git a/rhautoimport.pm b/rhautoimport.pm index bb0c015..6a7678f 100644 --- a/rhautoimport.pm +++ b/rhautoimport.pm @@ -33,7 +33,7 @@ use IO::Handle; use LWP::Simple; use XML::Feed; use RHRD::rddb; -use JSON; +use JSON::MaybeXS; use constant { @@ -106,7 +106,8 @@ sub parse_result my $result; eval { - $result = from_json($result_json); + my $j = JSON::MaybeXS->new(utf8 => 0); + $result = $j->decode($result_json); 1; } or do { $log .= "\n!! error parsing import result !!\n"; @@ -147,7 +148,7 @@ sub import_uri my %request; $request{'LOGIN_NAME'} = RD_USER; $request{'SHOW_ID'} = int($show_id); - $request{'CLEAR_SHOW_CARTS'} = JSON::true; + $request{'CLEAR_SHOW_CARTS'} = JSON->true; $request{'SOURCE_URI'} = $uri; $request{'SOURCE_FILE_POLICY'} = $file_policy if $file_policy; @@ -157,9 +158,12 @@ sub import_uri return (1, "can't create request file in watchdir\n") unless($fh); chmod(0660, $fh); + binmode($fh, ":utf8"); my $requestfile = $fh->filename; my $log = "request file written to '$requestfile' ... "; - print $fh to_json(\%request); + + my $j = JSON::MaybeXS->new(utf8 => 0); + print $fh $j->encode(\%request); print $fh "\n"; close $fh; -- cgit v0.10.2