aboutsummaryrefslogtreecommitdiffstats
path: root/lib/WWW/FairViewer/Search.pm
diff options
context:
space:
mode:
authortrizen <trizen@protonmail.com>2020-10-05 14:50:59 +0300
committerJesús <heckyel@hyperbola.info>2020-11-09 16:05:09 -0500
commitbe00b89005ffc38f257848b47d2e4a0b2a536c44 (patch)
treefeebe04b6c8a334123849a4ccecbe5db988a3718 /lib/WWW/FairViewer/Search.pm
parent76bf4687e70cc573ed4bb82fbdaa030d7b9e4d25 (diff)
downloadfair-viewer-be00b89005ffc38f257848b47d2e4a0b2a536c44.tar.lz
fair-viewer-be00b89005ffc38f257848b47d2e4a0b2a536c44.tar.xz
fair-viewer-be00b89005ffc38f257848b47d2e4a0b2a536c44.zip
- Implemented support for searching for videos from a specific channel.
Example: fair-viewer --author=SomeYouTubeUsername keywords-here In gtk-fair-viwer this is implemented via the "From author" field. Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'lib/WWW/FairViewer/Search.pm')
-rw-r--r--lib/WWW/FairViewer/Search.pm22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/WWW/FairViewer/Search.pm b/lib/WWW/FairViewer/Search.pm
index 6f4e8d0..69ae560 100644
--- a/lib/WWW/FairViewer/Search.pm
+++ b/lib/WWW/FairViewer/Search.pm
@@ -53,7 +53,6 @@ sub _make_search_url {
region => $self->get_region,
sort_by => $self->get_order,
date => $self->get_date,
- channelId => $self->get_channelId,
pageToken => $self->page_token,
duration => $self->get_videoDuration,
@@ -72,15 +71,28 @@ Search for a list of types (comma-separated).
sub search_for {
my ($self, $type, $keywords, $args) = @_;
+ if (ref($args) ne 'HASH') {
+ $args = {};
+ }
+
$keywords //= [];
- if (ref $keywords ne 'ARRAY') {
+
+ if (ref($keywords) ne 'ARRAY') {
$keywords = [split ' ', $keywords];
}
+ $keywords = $self->escape_string(join(' ', @{$keywords}));
+
+ # Search in a channel's videos
+ if (defined(my $channel_id = $self->get_channelId)) {
+ my $url = $self->_make_feed_url("channels/search/$channel_id", q => $keywords,);
+ return $self->_get_results($url);
+ }
+
my $url = $self->_make_search_url(
type => $type,
- q => $self->escape_string(join(' ', @{$keywords})),
- (ref $args eq 'HASH' ? %{$args} : (part => 'snippet')),
+ q => $keywords,
+ %$args,
);
return $self->_get_results($url);
@@ -104,7 +116,7 @@ sub search_for {
},
{
name => 'all',
- type => 'video,channel,playlist',
+ type => 'all',
}
) {
*{__PACKAGE__ . '::' . "search_$pair->{name}"} = sub {