0

Merge pull request #14 from l29ah/links

Add an option to print links to the tracks instead of fetching them
This commit is contained in:
Kaimi
2019-08-30 15:37:55 +03:00
committed by GitHub

View File

@@ -191,6 +191,8 @@ my ($opt, $usage) = Getopt::Long::Descriptive::describe_options
['Bitrate 320 is available only when subscription is active'], ['Bitrate 320 is available only when subscription is active'],
['and only via mobile API for now (be sure to specify Authorization header value)'], ['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'], ['debug', 'print debug info during work'],
['help', 'print usage'], ['help', 'print usage'],
[], [],
@@ -385,6 +387,10 @@ if($opt{album} || ($opt{playlist} && $opt{kind}))
next; next;
} }
if($opt{link})
{
print(get_track_url($track_info_ref->{dir}));
} else {
fetch_track($track_info_ref); fetch_track($track_info_ref);
if($opt{delay} && $track_info_ref != $track_list_info[-1]) if($opt{delay} && $track_info_ref != $track_list_info[-1])
@@ -393,6 +399,7 @@ if($opt{album} || ($opt{playlist} && $opt{kind}))
sleep $opt{delay}; sleep $opt{delay};
} }
} }
}
info(OK, 'Done!'); info(OK, 'Done!');
} }
@@ -1027,6 +1034,11 @@ sub info
{ {
my ($type, $msg) = @_; my ($type, $msg) = @_;
if($opt{silent} && $type ne ERROR)
{
return;
}
if($type eq DEBUG) if($type eq DEBUG)
{ {
return if !$opt{debug}; return if !$opt{debug};