diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fair-viewer | 15 | ||||
-rwxr-xr-x | bin/gtk-fair-viewer | 15 |
2 files changed, 20 insertions, 10 deletions
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 diff --git a/bin/gtk-fair-viewer b/bin/gtk-fair-viewer index bc9c747..42ab174 100755 --- a/bin/gtk-fair-viewer +++ b/bin/gtk-fair-viewer @@ -2404,16 +2404,14 @@ sub make_row_description { } sub append_next_page { - my ($url) = @_; - - #$token // return; # no next page is available - + my ($url, $continuation) = @_; my $iter = $liststore->append; $liststore->set( $iter, 0 => "<big><b>LOAD MORE</b></big>", 3 => $url, + 5 => $continuation, 7 => 'next_page', ); } @@ -2663,7 +2661,14 @@ sub display_results { } } - append_next_page($url); #, #$info->{nextPageToken}); + if (ref($results->{results}) eq 'HASH' and exists($results->{results}{continuation})) { + if (defined $results->{results}{continuation}) { + append_next_page($url, $results->{results}{continuation}); + } + } + else { + append_next_page($url); + } } sub set_entry_tooltip { |