diff options
Diffstat (limited to 'lib/WWW')
-rw-r--r-- | lib/WWW/FairViewer/Utils.pm | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/WWW/FairViewer/Utils.pm b/lib/WWW/FairViewer/Utils.pm index 0aaac4f..ccb5800 100644 --- a/lib/WWW/FairViewer/Utils.pm +++ b/lib/WWW/FairViewer/Utils.pm @@ -522,22 +522,29 @@ sub get_thumbnail_url { if ($info->{type} eq 'channel') { ref($info->{authorThumbnails}) eq 'ARRAY' or return ''; - return $info->{authorThumbnails}[0]{url}; + + foreach my $thumbnail (map { ref($_) eq 'ARRAY' ? @{$_} : $_ } @{$info->{authorThumbnails}}) { + if (exists $thumbnail->{quality} and $thumbnail->{quality} eq $type) { + return $thumbnail->{url}; + } + } + + return eval { $info->{authorThumbnails}[0]{url} } // ''; } ref($info->{videoThumbnails}) eq 'ARRAY' or return ''; - my @thumbs = @{$info->{videoThumbnails}}; - my @wanted = grep { $_->{quality} eq $type } @thumbs; + my @thumbs = map { ref($_) eq 'ARRAY' ? @{$_} : $_ } @{$info->{videoThumbnails}}; + my @wanted = grep { $_->{quality} eq $type } grep { ref($_) eq 'HASH' } @thumbs; my $url; if (@wanted) { - $url = $wanted[0]{url}; + $url = eval { $wanted[0]{url} } // return ''; } else { warn "[!] Couldn't find thumbnail of type <<$type>>..."; - $url = $thumbs[0]{url}; + $url = eval { $thumbs[0]{url} } // return ''; } # Clean URL of trackers and other junk @@ -773,7 +780,11 @@ sub get_comments { my ($self, $item) = @_; if ($pair->[0] eq 'video') { - return 1 if exists $item->{videoId}; + return 1 if defined $item->{videoId}; + } + + if ($pair->[0] eq 'playlist') { + return 1 if defined $item->{playlistId}; } exists $pair->[1]{$item->{type} // ''}; |