From e12231261f5ff06b278d5763123c233ad960ce93 Mon Sep 17 00:00:00 2001 From: Sergey Alirzaev Date: Thu, 15 Aug 2019 00:01:11 +0300 Subject: [PATCH 1/2] Add an option to print links to the tracks instead of fetching them --- src/ya.pl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ya.pl b/src/ya.pl index bde01ec..7aa6cfb 100755 --- a/src/ya.pl +++ b/src/ya.pl @@ -191,6 +191,7 @@ my ($opt, $usage) = Getopt::Long::Descriptive::describe_options ['Bitrate 320 is available only when subscription is active'], ['and only via mobile API for now (be sure to specify Authorization header value)'], [], + ['link|l', 'do not fetch, only print links to the tracks'], ['debug', 'print debug info during work'], ['help', 'print usage'], [], @@ -385,12 +386,17 @@ if($opt{album} || ($opt{playlist} && $opt{kind})) next; } - fetch_track($track_info_ref); - - if($opt{delay} && $track_info_ref != $track_list_info[-1]) + if($opt{link}) { - info(INFO, 'Waiting for ' . $opt{delay} . ' seconds'); - sleep $opt{delay}; + print(get_track_url($track_info_ref->{dir})); + } else { + fetch_track($track_info_ref); + + if($opt{delay} && $track_info_ref != $track_list_info[-1]) + { + info(INFO, 'Waiting for ' . $opt{delay} . ' seconds'); + sleep $opt{delay}; + } } } From 95173d9e0711d3ae498112d2d1bbb911235fba78 Mon Sep 17 00:00:00 2001 From: Sergey Alirzaev Date: Thu, 15 Aug 2019 00:01:45 +0300 Subject: [PATCH 2/2] Add an option for silent operation --- src/ya.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ya.pl b/src/ya.pl index 7aa6cfb..8f5f428 100755 --- a/src/ya.pl +++ b/src/ya.pl @@ -192,6 +192,7 @@ my ($opt, $usage) = Getopt::Long::Descriptive::describe_options ['and only via mobile API for now (be sure to specify Authorization header value)'], [], ['link|l', 'do not fetch, only print links to the tracks'], + ['silent|s', 'do not print informational messages'], ['debug', 'print debug info during work'], ['help', 'print usage'], [], @@ -1033,6 +1034,11 @@ sub info { my ($type, $msg) = @_; + if($opt{silent} && $type ne ERROR) + { + return; + } + if($type eq DEBUG) { return if !$opt{debug};