0

Fix to adjust to Yandex changes. Minor debug improvement

This commit is contained in:
Kaimi
2015-01-30 00:40:59 +03:00
parent 8633119e0c
commit 7a55a69249

19
src/ya.pl Executable file → Normal file
View File

@@ -235,7 +235,7 @@ sub get_track_url
return; return;
} }
my ($json_data) = ($request->as_string =~ /Ya\.Music\.Jsonp\.callback\(['"]\d+['"],\s*(.+?)\);/); my ($json_data) = $request->content;
if(!$json_data) if(!$json_data)
{ {
info(DEBUG, 'Can\'t parse JSON blob'); info(DEBUG, 'Can\'t parse JSON blob');
@@ -251,11 +251,11 @@ sub get_track_url
my %fields = my %fields =
( (
host => $json->[0]->{host}, host => $json->{host},
path => $json->[0]->{path}, path => $json->{path},
ts => $json->[0]->{ts}, ts => $json->{ts},
region => $json->[0]->{region}, region => $json->{region},
s => $json->[0]->{s} s => $json->{s}
); );
my $hash = hash(substr($fields{path}, 1) . $fields{s}); my $hash = hash(substr($fields{path}, 1) . $fields{s});
@@ -390,7 +390,12 @@ sub info
{ {
my ($type, $msg) = @_; 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? # Actual terminal width detection?
$msg = Term::ANSIColor::colored('['.$type.']', $log_colors{$type}) . ' ' . $msg; $msg = Term::ANSIColor::colored('['.$type.']', $log_colors{$type}) . ' ' . $msg;
$msg .= ' ' x (80 - length($msg) - length($\)); $msg .= ' ' x (80 - length($msg) - length($\));