aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/WWW/StrawViewer.pm33
-rw-r--r--lib/WWW/StrawViewer/Utils.pm23
-rw-r--r--lib/WWW/StrawViewer/Videos.pm5
3 files changed, 51 insertions, 10 deletions
diff --git a/lib/WWW/StrawViewer.pm b/lib/WWW/StrawViewer.pm
index 42206d1..de13099 100644
--- a/lib/WWW/StrawViewer.pm
+++ b/lib/WWW/StrawViewer.pm
@@ -130,6 +130,39 @@ sub _our_smartmatch {
return 0;
}
+sub basic_video_info_fields {
+ join(',',
+ qw(
+ title
+ videoId
+ description
+ published
+ publishedText
+ viewCount
+ likeCount
+ dislikeCount
+ genre
+ author
+ authorId
+ lengthSeconds
+ rating
+ liveNow
+ )
+ )
+}
+
+sub extra_video_info_fields {
+ my ($self) = @_;
+ join(',',
+ $self->basic_video_info_fields,
+ qw(
+ subCountText
+ captions
+ isFamilyFriendly
+ )
+ );
+}
+
{
no strict 'refs';
diff --git a/lib/WWW/StrawViewer/Utils.pm b/lib/WWW/StrawViewer/Utils.pm
index 062bbe1..f70afc0 100644
--- a/lib/WWW/StrawViewer/Utils.pm
+++ b/lib/WWW/StrawViewer/Utils.pm
@@ -228,12 +228,18 @@ sub has_entries {
return scalar @{$result->{results}{comments}} > 0;
}
- if ($result->{results}{type} eq 'playlist') {
+ my $type = $result->{results}{type}//'';
+
+ if ($type eq 'playlist') {
return $result->{results}{videoCount} > 0;
}
}
- scalar(@{$result->{results}}) > 0;
+ if (ref($result->{results}) eq 'ARRAY') {
+ return scalar(@{$result->{results}}) > 0;
+ }
+
+ return 1; # maybe?
#ref($result) eq 'HASH' and ($result->{results}{pageInfo}{totalResults} > 0);
}
@@ -530,7 +536,8 @@ sub get_channel_id {
sub get_category_id {
my ($self, $info) = @_;
#$info->{snippet}{resourceId}{categoryId} // $info->{snippet}{categoryId};
- "unknown";
+ #"unknown";
+ $info->{genre} // 'Unknown';
}
sub get_category_name {
@@ -554,7 +561,9 @@ sub get_category_name {
29 => 'Nonprofits & Activism',
};
- $categories->{$self->get_category_id($info) // ''} // 'Unknown';
+ #$categories->{$self->get_category_id($info) // ''} // 'Unknown';
+
+ $info->{genre} // 'Unknown';
}
sub get_publication_date {
@@ -677,14 +686,12 @@ sub get_views_approx {
sub get_likes {
my ($self, $info) = @_;
- #$info->{statistics}{likeCount};
- 0;
+ $info->{likeCount} // 0;
}
sub get_dislikes {
my ($self, $info) = @_;
- #$info->{statistics}{dislikeCount};
- 0;
+ $info->{dislikeCount} // 0;
}
sub get_comments {
diff --git a/lib/WWW/StrawViewer/Videos.pm b/lib/WWW/StrawViewer/Videos.pm
index 9df9ff3..11bf60b 100644
--- a/lib/WWW/StrawViewer/Videos.pm
+++ b/lib/WWW/StrawViewer/Videos.pm
@@ -186,8 +186,9 @@ When C<$part> is C<undef>, it defaults to I<snippet>.
=cut
sub video_details {
- my ($self, $id, $part) = @_;
- return $self->_get_results($self->_make_videos_url(id => $id, part => $part // 'snippet'));
+ my ($self, $id, $fields) = @_;
+ $fields //= $self->basic_video_info_fields;
+ $self->_get_results($self->_make_feed_url("videos/$id", fields => $fields));
}
=head2 Return details