From 7a55a692493f95549025968a33d4d0f8bf41640f Mon Sep 17 00:00:00 2001 From: Kaimi Date: Fri, 30 Jan 2015 00:40:59 +0300 Subject: [PATCH] Fix to adjust to Yandex changes. Minor debug improvement --- src/ya.pl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) mode change 100755 => 100644 src/ya.pl diff --git a/src/ya.pl b/src/ya.pl old mode 100755 new mode 100644 index 05834e6..20bb3f9 --- a/src/ya.pl +++ b/src/ya.pl @@ -235,7 +235,7 @@ sub get_track_url return; } - my ($json_data) = ($request->as_string =~ /Ya\.Music\.Jsonp\.callback\(['"]\d+['"],\s*(.+?)\);/); + my ($json_data) = $request->content; if(!$json_data) { info(DEBUG, 'Can\'t parse JSON blob'); @@ -251,11 +251,11 @@ sub get_track_url my %fields = ( - host => $json->[0]->{host}, - path => $json->[0]->{path}, - ts => $json->[0]->{ts}, - region => $json->[0]->{region}, - s => $json->[0]->{s} + host => $json->{host}, + path => $json->{path}, + ts => $json->{ts}, + region => $json->{region}, + s => $json->{s} ); my $hash = hash(substr($fields{path}, 1) . $fields{s}); @@ -390,7 +390,12 @@ sub info { my ($type, $msg) = @_; - return if !$opt->debug && $type eq DEBUG; + if($type eq DEBUG) + { + return if !$opt->debug; + # Func, line, msg + $msg = (caller(1))[3] . "(" . (caller(0))[2] . "): " . $msg; + } # Actual terminal width detection? $msg = Term::ANSIColor::colored('['.$type.']', $log_colors{$type}) . ' ' . $msg; $msg .= ' ' x (80 - length($msg) - length($\));