aboutsummaryrefslogtreecommitdiffstats
path: root/lib/WWW/StrawViewer/Utils.pm
diff options
context:
space:
mode:
authortrizen <trizen@protonmail.com>2020-02-15 06:18:27 +0200
committertrizen <trizen@protonmail.com>2020-02-15 06:18:27 +0200
commitd3c5fe3152d72c9ff8e926f5371b26441ba27e80 (patch)
tree511c03099c68f1eb4ff4ffa9f9d6351f442b0e87 /lib/WWW/StrawViewer/Utils.pm
parent21c134c5d9e2d620998a6c0a40ee98feec266177 (diff)
downloadfair-viewer-d3c5fe3152d72c9ff8e926f5371b26441ba27e80.tar.lz
fair-viewer-d3c5fe3152d72c9ff8e926f5371b26441ba27e80.tar.xz
fair-viewer-d3c5fe3152d72c9ff8e926f5371b26441ba27e80.zip
Added basic support for showing comments.
Diffstat (limited to 'lib/WWW/StrawViewer/Utils.pm')
-rw-r--r--lib/WWW/StrawViewer/Utils.pm44
1 files changed, 37 insertions, 7 deletions
diff --git a/lib/WWW/StrawViewer/Utils.pm b/lib/WWW/StrawViewer/Utils.pm
index 87a7ac0..062bbe1 100644
--- a/lib/WWW/StrawViewer/Utils.pm
+++ b/lib/WWW/StrawViewer/Utils.pm
@@ -222,8 +222,15 @@ Returns true if a given result has entries.
sub has_entries {
my ($self, $result) = @_;
- if (ref($result->{results}) eq 'HASH' and $result->{results}{type} eq 'playlist') {
- return $result->{results}{videoCount} > 0;
+ if (ref($result->{results}) eq 'HASH') {
+
+ if (exists $result->{results}{comments}) {
+ return scalar @{$result->{results}{comments}} > 0;
+ }
+
+ if ($result->{results}{type} eq 'playlist') {
+ return $result->{results}{videoCount} > 0;
+ }
}
scalar(@{$result->{results}}) > 0;
@@ -424,6 +431,11 @@ sub get_playlist_id {
$info->{playlistId};
}
+sub get_playlist_video_count {
+ my ($self, $info) = @_;
+ $info->{videoCount};
+}
+
=head2 get_description($info)
Get description.
@@ -488,6 +500,21 @@ sub get_channel_title {
$info->{author};
}
+sub get_author {
+ my ($self, $info) = @_;
+ $info->{author};
+}
+
+sub get_comment_id {
+ my ($self, $info) = @_;
+ $info->{commentId};
+}
+
+sub get_comment_content {
+ my ($self, $info) = @_;
+ $info->{content};
+}
+
sub get_id {
my ($self, $info) = @_;
#$info->{id};
@@ -541,13 +568,13 @@ sub get_publication_date {
sub get_publication_age {
my ($self, $info) = @_;
- $info->{publishedText} =~ s/\sago\z//r;;
+ ($info->{publishedText} // '') =~ s/\sago\z//r;;
}
sub get_publication_age_approx {
my ($self, $info) = @_;
- my $age = $self->get_publication_age($info);
+ my $age = $self->get_publication_age($info) // '';
if ($age =~ /hour|min|sec/) {
return "0d";
@@ -650,17 +677,20 @@ sub get_views_approx {
sub get_likes {
my ($self, $info) = @_;
- $info->{statistics}{likeCount};
+ #$info->{statistics}{likeCount};
+ 0;
}
sub get_dislikes {
my ($self, $info) = @_;
- $info->{statistics}{dislikeCount};
+ #$info->{statistics}{dislikeCount};
+ 0;
}
sub get_comments {
my ($self, $info) = @_;
- $info->{statistics}{commentCount};
+ #$info->{statistics}{commentCount};
+ 1;
}
{