diff options
Diffstat (limited to 'lib/WWW/StrawViewer')
-rw-r--r-- | lib/WWW/StrawViewer/CommentThreads.pm | 13 | ||||
-rw-r--r-- | lib/WWW/StrawViewer/Utils.pm | 44 |
2 files changed, 41 insertions, 16 deletions
diff --git a/lib/WWW/StrawViewer/CommentThreads.pm b/lib/WWW/StrawViewer/CommentThreads.pm index 499d930..1eba143 100644 --- a/lib/WWW/StrawViewer/CommentThreads.pm +++ b/lib/WWW/StrawViewer/CommentThreads.pm @@ -36,15 +36,10 @@ Retrieve comments from a video ID. sub comments_from_video_id { my ($self, $video_id) = @_; - return - $self->_get_results( - $self->_make_commentThreads_url( - videoId => $video_id, - textFormat => 'plainText', - order => $self->get_comments_order, - part => 'snippet,replies' - ), - simple => 1, + $self->_get_results( + $self->_make_feed_url("comments/$video_id", + sort_by => $self->get_comments_order, + ), ); } 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; } { |