Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

JSON too slow for Raspberry Pi

  • Loading branch information...
commit 1d2636ee002d13530cc06b93ad7182763ef1c859 1 parent 62a7f6f
@msoap authored
View
8 helpers/on_status_display.pl
@@ -11,14 +11,14 @@ =head1 DESCRIPTION
use strict;
use warnings;
-use JSON;
-
# ------------------------------------------------------------------------------
sub main {
my %params = @ARGV;
- open my $FH, '>', "$ENV{HOME}/.cmus/last_track.json" or die "Error open file: $!\n";
- print $FH to_json(\%params) . "\n";
+ open my $FH, '>', "$ENV{HOME}/.cmus/last_track.tsv" or die "Error open file: $!\n";
+ for my $key (keys %params) {
+ print $FH "$key\t$params{$key}\n";
+ }
close $FH;
}
View
9 mojolicious-radio-box.pl
@@ -23,7 +23,7 @@ =head1 Mojolicious radio box
our %OPTIONS = (
ini_file => "$ENV{HOME}/.cmus/mojolicious-radio-box.ini",
- last_track_file => "$ENV{HOME}/.cmus/last_track.json",
+ last_track_file => "$ENV{HOME}/.cmus/last_track.tsv",
playlist_file => "$ENV{HOME}/.cmus/playlist.pl",
listen_address => 'http://*:8080',
hypnotoad_workers => 5,
@@ -130,7 +130,12 @@ sub cmus_get_info {
)
{
open my $FH, '<', $OPTIONS{last_track_file} or die "Error open file: $!\n";
- my $add_info = eval{from_json(join("", <$FH>))} || {};
+ my $add_info = {};
+ while (my $line = <$FH>) {
+ chomp $line;
+ my ($key, $value) = split "\t", $line, 2;
+ $add_info->{$key} = $value if length($key) > 0;
+ }
$info->{radio_title} = $add_info->{title} if $add_info->{title};
close $FH;
}
View
7 src/cmus-client.pm
@@ -27,7 +27,12 @@ sub cmus_get_info {
)
{
open my $FH, '<', $OPTIONS{last_track_file} or die "Error open file: $!\n";
- my $add_info = eval{from_json(join("", <$FH>))} || {};
+ my $add_info = {};
+ while (my $line = <$FH>) {
+ chomp $line;
+ my ($key, $value) = split "\t", $line, 2;
+ $add_info->{$key} = $value if length($key) > 0;
+ }
$info->{radio_title} = $add_info->{title} if $add_info->{title};
close $FH;
}
View
2  src/mojolicious-lite-radio-box-server.pl
@@ -23,7 +23,7 @@ =head1 Mojolicious radio box
our %OPTIONS = (
ini_file => "$ENV{HOME}/.cmus/mojolicious-radio-box.ini",
- last_track_file => "$ENV{HOME}/.cmus/last_track.json",
+ last_track_file => "$ENV{HOME}/.cmus/last_track.tsv",
playlist_file => "$ENV{HOME}/.cmus/playlist.pl",
listen_address => 'http://*:8080',
hypnotoad_workers => 5,
Please sign in to comment.
Something went wrong with that request. Please try again.