aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrizen <trizen@protonmail.com>2020-03-06 03:34:55 +0200
committerJesús <heckyel@hyperbola.info>2020-03-07 13:57:09 -0500
commit82dacf03883cacbb27aad0fadee541e82684f299 (patch)
tree0af68180b1b7467cccbc066a254b8e052a0b93b7
parentbcc2d0bedcd582de39da89aaf6762ffe0aac5fa0 (diff)
downloadfair-viewer-82dacf03883cacbb27aad0fadee541e82684f299.tar.lz
fair-viewer-82dacf03883cacbb27aad0fadee541e82684f299.tar.xz
fair-viewer-82dacf03883cacbb27aad0fadee541e82684f299.zip
- Implemented support for playlists from username.
-rwxr-xr-xbin/fair-viewer10
-rwxr-xr-xbin/gtk-fair-viewer12
-rw-r--r--lib/WWW/FairViewer/Playlists.pm12
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()