From 1cddf3aff73e53e07c816b9974347d4dbe8c33c3 Mon Sep 17 00:00:00 2001 From: trizen Date: Fri, 6 Mar 2020 04:45:26 +0200 Subject: - Support for next pages of playlists from username. - Better detection for the last page of results. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jesús --- bin/fair-viewer | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'bin/fair-viewer') diff --git a/bin/fair-viewer b/bin/fair-viewer index 83d35e2..76fb6a8 100755 --- a/bin/fair-viewer +++ b/bin/fair-viewer @@ -2269,7 +2269,14 @@ sub general_options { my $callback = $args{sub}; my $results = $args{res}; my $info = $args{info}; - my $token = $args{token}; + + my $token = undef; + my $has_token = 0; + + if (ref($info->{results}) eq 'HASH' and exists $info->{results}{continuation}) { + $has_token = 1; + $token = $info->{results}{continuation}; + } if (not defined($option)) { return; @@ -2279,9 +2286,9 @@ sub general_options { main_quit(0); } elsif ($option =~ /^(?:n|next)\z/ and defined $url) { - if (exists $args{token}) { + if ($has_token) { if (defined $token) { - my $request = $yv_obj->next_page_with_token($url, $token); + my $request = $yv_obj->next_page($url, $token); $callback->($request); } else { @@ -2639,7 +2646,6 @@ sub print_comments { my $url = $results->{url}; my $comments = $results->{results}{comments} // []; - my $token = $results->{results}{continuation}; my $i = 0; foreach my $comment (@{$comments}) { @@ -2698,7 +2704,6 @@ sub print_comments { info => $results, mode => 'comments', args => [$videoID], - token => $token, ) ) { ## ok -- cgit v1.2.3