From 9627e95b1964a23f833ee3efb6b81810bc040240 Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 14 Apr 2024 19:45:06 +0200 Subject: [PATCH 1/2] invidious/invidious.php aktualisiert Now intercepts YouTube links without a leading "www". --- invidious/invidious.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/invidious/invidious.php b/invidious/invidious.php index 1078d26d..6ae9bc78 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -2,7 +2,7 @@ /* * Name: invidious * Description: Replaces links to youtube.com to an invidious instance in all displays of postings on a node. - * Version: 0.3 + * Version: 0.4 * Author: Matthias Ebers * Author: Michael Vogel * Status: Unsupported @@ -96,6 +96,9 @@ function invidious_render(array &$b) $b['html'] = preg_replace("/https?:\/\/www.youtube.com\/watch\?v\=(.*?)/ism", $server . '/watch?v=$1', $b['html']); $b['html'] = preg_replace("/https?:\/\/www.youtube.com\/embed\/(.*?)/ism", $server . '/embed/$1', $b['html']); $b['html'] = preg_replace("/https?:\/\/www.youtube.com\/shorts\/(.*?)/ism", $server . '/shorts/$1', $b['html']); + $b['html'] = preg_replace("/https?:\/\/youtube.com\/watch\?v\=(.*?)/ism", $server . '/watch?v=$1', $b['html']); + $b['html'] = preg_replace("/https?:\/\/youtube.com\/embed\/(.*?)/ism", $server . '/embed/$1', $b['html']); + $b['html'] = preg_replace("/https?:\/\/youtube.com\/shorts\/(.*?)/ism", $server . '/shorts/$1', $b['html']); $b['html'] = preg_replace("/https?:\/\/youtu.be\/(.*?)/ism", $server . '/watch?v=$1', $b['html']); if ($original != $b['html']) { From 3bf547ee6e778fff9137bd9fc11a8f2dd6ec8d39 Mon Sep 17 00:00:00 2001 From: loma-one Date: Mon, 15 Apr 2024 06:02:58 +0200 Subject: [PATCH 2/2] invidious/invidious.php aktualisiert Note taken from @MrPetovan --- invidious/invidious.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/invidious/invidious.php b/invidious/invidious.php index 6ae9bc78..7153aab9 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -93,12 +93,9 @@ function invidious_render(array &$b) $original = $b['html']; $server = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'invidious', 'server', DI::config()->get('invidious', 'server', INVIDIOUS_DEFAULT)); - $b['html'] = preg_replace("/https?:\/\/www.youtube.com\/watch\?v\=(.*?)/ism", $server . '/watch?v=$1', $b['html']); - $b['html'] = preg_replace("/https?:\/\/www.youtube.com\/embed\/(.*?)/ism", $server . '/embed/$1', $b['html']); - $b['html'] = preg_replace("/https?:\/\/www.youtube.com\/shorts\/(.*?)/ism", $server . '/shorts/$1', $b['html']); - $b['html'] = preg_replace("/https?:\/\/youtube.com\/watch\?v\=(.*?)/ism", $server . '/watch?v=$1', $b['html']); - $b['html'] = preg_replace("/https?:\/\/youtube.com\/embed\/(.*?)/ism", $server . '/embed/$1', $b['html']); - $b['html'] = preg_replace("/https?:\/\/youtube.com\/shorts\/(.*?)/ism", $server . '/shorts/$1', $b['html']); + $b['html'] = preg_replace("~https?://(?:www\.)?youtube\.com/watch\?v=(.*?)~ism", $server . '/watch?v=$1', $b['html']); + $b['html'] = preg_replace("~https?://(?:www\.)?youtube\.com/embed/(.*?)~ism", $server . '/embed/$1', $b['html']); + $b['html'] = preg_replace("~https?://(?:www\.)?youtube\.com/shorts/(.*?)~ism", $server . '/shorts/$1', $b['html']); $b['html'] = preg_replace("/https?:\/\/youtu.be\/(.*?)/ism", $server . '/watch?v=$1', $b['html']); if ($original != $b['html']) {