aboutsummaryrefslogtreecommitdiffstats
path: root/lib/WWW/FairViewer/Search.pm
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-07-09 15:27:16 -0500
committerJesús <heckyel@hyperbola.info>2021-07-09 15:27:16 -0500
commit739c821a54c01816e60eb5f774c8977a1e221ea0 (patch)
treee04a7f5a6fe4d450d43fd45c412f9d415bcb7a7e /lib/WWW/FairViewer/Search.pm
parentc1322a4e9a1fb0a286dab1277a740072d0ab30f9 (diff)
downloadfair-viewer-739c821a54c01816e60eb5f774c8977a1e221ea0.tar.lz
fair-viewer-739c821a54c01816e60eb5f774c8977a1e221ea0.tar.xz
fair-viewer-739c821a54c01816e60eb5f774c8977a1e221ea0.zip
upstream
Diffstat (limited to 'lib/WWW/FairViewer/Search.pm')
-rw-r--r--lib/WWW/FairViewer/Search.pm25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/WWW/FairViewer/Search.pm b/lib/WWW/FairViewer/Search.pm
index 7242637..68f4521 100644
--- a/lib/WWW/FairViewer/Search.pm
+++ b/lib/WWW/FairViewer/Search.pm
@@ -6,7 +6,7 @@ use warnings;
=head1 NAME
-WWW::FairViewer::Search - Search functions for Fair API v3
+WWW::FairViewer::Search - Search for stuff on YouTube
=head1 SYNOPSIS
@@ -85,16 +85,26 @@ sub search_for {
# 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,);
+
+ $self->set_channelId(); # clear the channel ID
+
+ if (my $results = $self->yt_channel_search($channel_id, q => $keywords, type => $type, %$args)) {
+ return $results;
+ }
+
+ my $url = $self->_make_feed_url("channels/search/$channel_id", q => $keywords);
return $self->_get_results($url);
}
+ if (my $results = $self->yt_search(q => $keywords, type => $type, %$args)) {
+ return $results;
+ }
+
my $url = $self->_make_search_url(
type => $type,
q => $keywords,
- %$args,
+ %$args
);
-
return $self->_get_results($url);
}
@@ -161,15 +171,12 @@ be set to a YouTube video ID.
sub related_to_videoID {
my ($self, $videoID) = @_;
- my %info = $self->_get_video_info($videoID);
- my $watch_next_response = $self->parse_json_string($info{watch_next_response});
+ my $watch_next_response = $self->parse_json_string($self->_get_video_next_info($videoID) // return {results => []});
+
my $related =
eval { $watch_next_response->{contents}{twoColumnWatchNextResults}{secondaryResults}{secondaryResults}{results} }
// return {results => []};
- #use Data::Dump qw(pp);
- #pp $related;
-
my @results;
foreach my $entry (@$related) {