diff options
author | trizen <trizen@protonmail.com> | 2020-11-05 15:30:51 +0200 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-11-09 17:46:05 -0500 |
commit | 220990f6a15929adc234de59e4f8908a7b2418ab (patch) | |
tree | 80f5fe01a36e1627b1610a8135e367992de82952 /lib/WWW/FairViewer/Utils.pm | |
parent | 2b36daf98cc27fafc1a980f7d8d1f1e5d38a75a7 (diff) | |
download | fair-viewer-220990f6a15929adc234de59e4f8908a7b2418ab.tar.lz fair-viewer-220990f6a15929adc234de59e4f8908a7b2418ab.tar.xz fair-viewer-220990f6a15929adc234de59e4f8908a7b2418ab.zip |
Minor code tweaks in Utils `has_entries()`
Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'lib/WWW/FairViewer/Utils.pm')
-rw-r--r-- | lib/WWW/FairViewer/Utils.pm | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/WWW/FairViewer/Utils.pm b/lib/WWW/FairViewer/Utils.pm index 0144aec..b2b00ee 100644 --- a/lib/WWW/FairViewer/Utils.pm +++ b/lib/WWW/FairViewer/Utils.pm @@ -229,19 +229,20 @@ sub has_entries { foreach my $type (qw(comments videos playlists)) { if (exists $result->{results}{$type}) { - return scalar @{$result->{results}{$type}} > 0; + ref($result->{results}{$type}) eq 'ARRAY' or return 0; + return (@{$result->{results}{$type}} > 0); } } my $type = $result->{results}{type} // ''; if ($type eq 'playlist') { - return $result->{results}{videoCount} > 0; + return ($result->{results}{videoCount} > 0); } } if (ref($result->{results}) eq 'ARRAY') { - return scalar(@{$result->{results}}) > 0; + return (@{$result->{results}} > 0); } if (ref($result->{results}) eq 'HASH' and not keys %{$result->{results}}) { |