diff options
Diffstat (limited to 'lib/WWW/FairViewer/Utils.pm')
-rw-r--r-- | lib/WWW/FairViewer/Utils.pm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/WWW/FairViewer/Utils.pm b/lib/WWW/FairViewer/Utils.pm index e50bf3f..06ea9d9 100644 --- a/lib/WWW/FairViewer/Utils.pm +++ b/lib/WWW/FairViewer/Utils.pm @@ -230,7 +230,7 @@ sub has_entries { } } - my $type = $result->{results}{type}//''; + my $type = $result->{results}{type} // ''; if ($type eq 'playlist') { return $result->{results}{videoCount} > 0; @@ -241,6 +241,10 @@ sub has_entries { return scalar(@{$result->{results}}) > 0; } + if (ref($result->{results}) eq 'HASH' and not keys %{$result->{results}}) { + return 0; + } + return 1; # maybe? #ref($result) eq 'HASH' and ($result->{results}{pageInfo}{totalResults} > 0); } @@ -458,6 +462,7 @@ sub get_description { require URI::Escape; require HTML::Entities; + # Decode external links $desc =~ s{<a href="/redirect\?(.*?)".*?>.*?</a>}{ my $url = $1; if ($url =~ /(?:^|;)q=([^&]+)/) { @@ -468,6 +473,13 @@ sub get_description { } }segi; + # Decode internal links to videos / playlists + $desc =~ s{<a href="/(watch\?.*?)".*?>(https://www\.youtube\.com)/watch\?.*?</a>}{ + my $url = $2; + my $params = URI::Escape::uri_unescape($1); + "$url/$params"; + }segi; + $desc =~ s{<br/?>}{\n}gi; $desc =~ s{<a href=".*?".*?>(.*?)</a>}{$1}sgi; $desc =~ s/<.*?>//gs; |