aboutsummaryrefslogtreecommitdiffstats
path: root/lib/WWW/FairViewer
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WWW/FairViewer')
-rw-r--r--lib/WWW/FairViewer/Channels.pm5
-rw-r--r--lib/WWW/FairViewer/GuideCategories.pm2
-rw-r--r--lib/WWW/FairViewer/VideoCategories.pm48
-rw-r--r--lib/WWW/FairViewer/Videos.pm31
4 files changed, 22 insertions, 64 deletions
diff --git a/lib/WWW/FairViewer/Channels.pm b/lib/WWW/FairViewer/Channels.pm
index c554044..3ee44d4 100644
--- a/lib/WWW/FairViewer/Channels.pm
+++ b/lib/WWW/FairViewer/Channels.pm
@@ -41,6 +41,11 @@ Get the most popular videos for a given channel ID.
sub popular_videos {
my ($self, $channel_id) = @_;
+
+ if (not defined($channel_id)) { # trending popular videos
+ return $self->_get_results($self->_make_feed_url('popular'));
+ }
+
return $self->_get_results($self->_make_feed_url("channels/$channel_id/videos", sort_by => 'popular'));
}
diff --git a/lib/WWW/FairViewer/GuideCategories.pm b/lib/WWW/FairViewer/GuideCategories.pm
index a348abb..cead9f6 100644
--- a/lib/WWW/FairViewer/GuideCategories.pm
+++ b/lib/WWW/FairViewer/GuideCategories.pm
@@ -25,7 +25,7 @@ sub _make_guideCategories_url {
$opts{region} //= $self->get_region;
}
- $self->_make_feed_url('guideCategories', hl => $self->get_hl, %opts);
+ $self->_make_feed_url('guideCategories', %opts);
}
=head2 guide_categories(;$region_id)
diff --git a/lib/WWW/FairViewer/VideoCategories.pm b/lib/WWW/FairViewer/VideoCategories.pm
index 85045fd..4dfc125 100644
--- a/lib/WWW/FairViewer/VideoCategories.pm
+++ b/lib/WWW/FairViewer/VideoCategories.pm
@@ -18,16 +18,6 @@ WWW::FairViewer::VideoCategories - videoCategory resource handler.
=cut
-sub _make_videoCategories_url {
- my ($self, %opts) = @_;
-
- $self->_make_feed_url(
- 'videoCategories',
- hl => $self->get_hl,
- %opts,
- );
-}
-
=head2 video_categories()
Return video categories for a specific region ID.
@@ -37,37 +27,13 @@ Return video categories for a specific region ID.
sub video_categories {
my ($self) = @_;
- require File::Spec;
-
- my $region = $self->get_region() // 'US';
- my $url = $self->_make_videoCategories_url(region => $region);
- my $file = File::Spec->catfile($self->get_config_dir, "categories-$region-" . $self->get_hl() . ".json");
-
- my $json;
- if (open(my $fh, '<:utf8', $file)) {
- local $/;
- $json = <$fh>;
- close $fh;
- }
- else {
- $json = $self->lwp_get($url, simple => 1);
- open my $fh, '>:utf8', $file;
- print {$fh} $json;
- close $fh;
- }
-
- return $self->parse_json_string($json);
-}
-
-=head2 video_category_id_info($cagegory_id)
-
-Return info for the comma-separated specified category ID(s).
-
-=cut
-
-sub video_category_id_info {
- my ($self, $id) = @_;
- return $self->_get_results($self->_make_videoCategories_url(id => $id));
+ return [{id => "music", title => "Music"},
+ {id => "gaming", title => "Gaming"},
+ {id => "news", title => "News"},
+ {id => "movies", title => "Movies"},
+ {id => "trending", title => "Trending"},
+ {id => "popular", title => "Popular"},
+ ];
}
=head1 AUTHOR
diff --git a/lib/WWW/FairViewer/Videos.pm b/lib/WWW/FairViewer/Videos.pm
index aaaacc7..4acd866 100644
--- a/lib/WWW/FairViewer/Videos.pm
+++ b/lib/WWW/FairViewer/Videos.pm
@@ -48,22 +48,6 @@ sub _make_videos_url {
}
}
-=head2 videos_from_category($category_id)
-
-Get videos from a category ID.
-
-=cut
-
-sub videos_from_category {
- my ($self, $cat_id) = @_;
- $self->_get_results(
- $self->_make_videos_url(
- chart => $self->get_chart,
- videoCategoryId => $cat_id,
- )
- );
-}
-
=head2 trending_videos_from_category($category_id)
Get popular videos from a category ID.
@@ -71,14 +55,17 @@ Get popular videos from a category ID.
=cut
sub trending_videos_from_category {
- my ($self, $cat_id) = @_;
+ my ($self, $category) = @_;
+
+ if (defined($category) and $category eq 'popular') {
+ return $self->popular_videos;
+ }
- my $results = do {
- local $self->{videoCategoryId} = $cat_id;
- $self->search_videos("");
- };
+ if (defined($category) and $category eq 'trending') {
+ $category = undef;
+ }
- return $results;
+ return $self->_get_results($self->_make_feed_url('trending', (defined($category) ? (type => $category) : ())));
}
=head2 my_likes()