diff options
-rwxr-xr-x | bin/fair-viewer | 10 | ||||
-rwxr-xr-x | bin/gtk-fair-viewer | 12 | ||||
-rw-r--r-- | lib/WWW/FairViewer/Playlists.pm | 12 |
3 files changed, 23 insertions, 11 deletions
diff --git a/bin/fair-viewer b/bin/fair-viewer index e20192b..83d35e2 100755 --- a/bin/fair-viewer +++ b/bin/fair-viewer @@ -2829,6 +2829,16 @@ sub print_playlists { my $url = $results->{url}; my $playlists = $results->{results} // []; + if (ref($playlists) eq 'HASH') { + if (exists $playlists->{playlists}) { + $playlists = $playlists->{playlists}; + } + else { + warn "\n[!] No playlists...\n"; + $playlists = []; + } + } + state $info_format = <<"FORMAT"; TITLE: %s diff --git a/bin/gtk-fair-viewer b/bin/gtk-fair-viewer index 1935018..bc9c747 100755 --- a/bin/gtk-fair-viewer +++ b/bin/gtk-fair-viewer @@ -2535,7 +2535,17 @@ sub display_results { #pp $items; if (ref($items) eq 'HASH') { - $items = $items->{videos}; + + if (exists $items->{videos}) { + $items = $items->{videos}; + } + elsif (exists $items->{playlists}) { + $items = $items->{playlists}; + } + else { + warn "[!] No results...\n"; + $items = []; + } } hide_feeds_window(); diff --git a/lib/WWW/FairViewer/Playlists.pm b/lib/WWW/FairViewer/Playlists.pm index b4e8412..9f40453 100644 --- a/lib/WWW/FairViewer/Playlists.pm +++ b/lib/WWW/FairViewer/Playlists.pm @@ -27,7 +27,6 @@ sub _make_playlists_url { $self->_make_feed_url( 'playlists', - pageToken => $self->page_token, %opts, ); } @@ -64,13 +63,7 @@ Get and return playlists from a channel ID. sub playlists { my ($self, $channel_id) = @_; - $self->_get_results( - $self->_make_playlists_url( - ($channel_id and $channel_id ne 'mine') - ? (channelId => $channel_id) - : do { $self->get_access_token() // return; (mine => 'true') } - ) - ); + $self->_get_results($self->_make_feed_url("channels/playlists/$channel_id")); } =head2 playlists_from_username($username) @@ -81,8 +74,7 @@ Get and return the playlists created for a given username. sub playlists_from_username { my ($self, $username) = @_; - my $channel_id = $self->channel_id_from_username($username) // $username; - $self->playlists($channel_id); + $self->playlists($username); } =head2 my_playlists() |