aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrizen <trizen@protonmail.com>2020-08-02 14:21:12 +0300
committerJesús <heckyel@hyperbola.info>2020-08-07 12:46:16 -0500
commitad3d9dec0bbbac9fe6b4e7894272de341041b44c (patch)
tree787549dd9cdc9c946ae8ab5e5128342c924ad9a1
parent09356996f82a8cd55cac1f02daf89e3f9deb8433 (diff)
downloadfair-viewer-ad3d9dec0bbbac9fe6b4e7894272de341041b44c.tar.lz
fair-viewer-ad3d9dec0bbbac9fe6b4e7894272de341041b44c.tar.xz
fair-viewer-ad3d9dec0bbbac9fe6b4e7894272de341041b44c.zip
In description, handle decoding of `youtu.be` links and other internal URLs.
Signed-off-by: Jesús <heckyel@hyperbola.info>
-rw-r--r--lib/WWW/FairViewer/Utils.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/WWW/FairViewer/Utils.pm b/lib/WWW/FairViewer/Utils.pm
index 5521a2e..9f4afbc 100644
--- a/lib/WWW/FairViewer/Utils.pm
+++ b/lib/WWW/FairViewer/Utils.pm
@@ -486,6 +486,16 @@ sub get_description {
"$url/$params";
}segi;
+ # Decode internal youtu.be links
+ $desc =~ s{<a href="/watch\?v=(.*?)".*?>(https://youtu\.be)/.*?</a>}{
+ my $url = $2;
+ my $params = URI::Escape::uri_unescape($1);
+ "$url/$params";
+ }segi;
+
+ # Decode other internal links
+ $desc =~ s{<a href="/(.*?)".*?>.*?</a>}{https://youtube.com/$1}sgi;
+
$desc =~ s{<br/?>}{\n}gi;
$desc =~ s{<a href="(.*?)".*?>.*?</a>}{$1}sgi;
$desc =~ s/<.*?>//gs;