0

check for album availability via mobile api. web api is not available for now

This commit is contained in:
kaimi-
2016-10-04 21:43:50 +03:00
parent 3fc2bfce37
commit 925ad75c26

View File

@@ -284,7 +284,7 @@ if($opt{album} || ($opt{playlist} && $opt{kind}))
@track_list_info = get_album_tracks_info($opt{album}); @track_list_info = get_album_tracks_info($opt{album});
if($opt{track}) if(scalar @track_list_info > 0 && $opt{track})
{ {
info(INFO, 'Filtering single track: ' . $opt{track} . ' [' . $opt{album} . ']'); info(INFO, 'Filtering single track: ' . $opt{track} . ' [' . $opt{album} . ']');
@track_list_info = grep @track_list_info = grep
@@ -431,6 +431,7 @@ sub download_track
$whole_file = ''; $whole_file = '';
$total_size = $request->headers->content_length; $total_size = $request->headers->content_length;
info(DEBUG, 'File size from header: ' . $total_size); info(DEBUG, 'File size from header: ' . $total_size);
$request = $ua->get($url, ':content_cb' => \&progress); $request = $ua->get($url, ':content_cb' => \&progress);
@@ -601,6 +602,12 @@ sub get_album_tracks_info
info(INFO, 'Album title: ' . $title); info(INFO, 'Album title: ' . $title);
info(INFO, 'Tracks total: ' . $json->{$parent}->{trackCount}); info(INFO, 'Tracks total: ' . $json->{$parent}->{trackCount});
if($opt{mobile} && !$json->{$parent}->{availableForMobile})
{
info(ERROR, 'Album is not available via Mobile API');
return;
}
my @tracks = (); my @tracks = ();
for my $vol(@{$json->{$parent}->{volumes}}) for my $vol(@{$json->{$parent}->{volumes}})
{ {