1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
package WWW::FairViewer::Playlists;
use utf8;
use 5.014;
use warnings;
=head1 NAME
WWW::FairViewer::Playlists - YouTube playlists related mehods.
=head1 SYNOPSIS
use WWW::FairViewer;
my $obj = WWW::FairViewer->new(%opts);
my $info = $obj->playlist_from_id($playlist_id);
=head1 SUBROUTINES/METHODS
=cut
sub _make_playlists_url {
my ($self, %opts) = @_;
if (not exists $opts{'part'}) {
$opts{'part'} = 'snippet,contentDetails';
}
$self->_make_feed_url('playlists', %opts,);
}
sub get_playlist_id {
my ($self, $playlist_name, %fields) = @_;
my $url = $self->_simple_feeds_url('channels', qw(part contentDetails), %fields);
my $res = $self->_get_results($url);
ref($res->{results}{items}) eq 'ARRAY' || return;
@{$res->{results}{items}} || return;
return $res->{results}{items}[0]{contentDetails}{relatedPlaylists}{$playlist_name};
}
=head2 playlist_from_id($playlist_id)
Return info for one or more playlists.
PlaylistIDs can be separated by commas.
=cut
sub playlist_from_id {
my ($self, $id, $part) = @_;
$self->_get_results($self->_make_playlists_url(id => $id, part => ($part // 'snippet')));
}
=head2 playlists($channel_id)
Get and return playlists from a channel ID.
=cut
sub playlists {
my ($self, $channel_id) = @_;
if (my $results = $self->yt_channel_playlists($channel_id)) {
return $results;
}
my $url = $self->_make_feed_url("channels/playlists/$channel_id");
$self->_get_results($url);
}
=head2 playlists_from_username($username)
Get and return the playlists created for a given username.
=cut
sub playlists_from_username {
my ($self, $username) = @_;
$self->playlists($username);
}
=head2 my_playlists()
Get and return your playlists.
=cut
sub my_playlists {
my ($self) = @_;
$self->get_access_token() // return;
$self->_get_results($self->_make_playlists_url(mine => 'true'));
}
=head1 AUTHOR
Trizen, C<< <echo dHJpemVuQHByb3Rvbm1haWwuY29tCg== | base64 -d> >>
Jesus, C<< <echo aGVja3llbEBoeXBlcmJvbGEuaW5mbw== | base64 -d> >>
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc WWW::FairViewer::Playlists
=head1 LICENSE AND COPYRIGHT
Copyright 2013-2015 Trizen.
Copyright 2020 Jesus E.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See L<http://dev.perl.org/licenses/> for more information.
=cut
1; # End of WWW::FairViewer::Playlists
|