From 706be9a4297517a3103d53c71d6247419b31f888 Mon Sep 17 00:00:00 2001 From: emindemir1541 Date: Sat, 6 Sep 2025 17:04:58 +0300 Subject: [PATCH 1/6] check if it is short youtube video; if it is short, convert to youtube watch link --- xExtension-YouTube/extension.php | 55 +++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/xExtension-YouTube/extension.php b/xExtension-YouTube/extension.php index f33d436..b82f75c 100644 --- a/xExtension-YouTube/extension.php +++ b/xExtension-YouTube/extension.php @@ -61,6 +61,20 @@ public function isYtFeed(string $website): bool { return str_starts_with($website, 'https://www.youtube.com/'); } + public function isShort(string $website): bool { + return str_starts_with($website, 'https://www.youtube.com/shorts'); + } + public function convertShortToWatch(string $shortUrl): string { + $prefix = 'https://www.youtube.com/shorts/'; + + if (str_starts_with($shortUrl, $prefix)) { + $videoId = str_replace($prefix, '', $shortUrl); + return 'https://www.youtube.com/watch?v=' . $videoId; + } + + return $shortUrl; + } + public function iconBtnUrl(FreshRSS_Feed $feed): ?string { if (!$this->isYtFeed($feed->website()) || $feed->attributeString('customFaviconExt') === $this->getName()) { return null; @@ -373,31 +387,34 @@ public function isUseNoCookieDomain(): bool * Inserts the YouTube video iframe into the content of an entry, if the entries link points to a YouTube watch URL. * @throws FreshRSS_Context_Exception */ - public function embedYouTubeVideo(FreshRSS_Entry $entry): FreshRSS_Entry - { - $link = $entry->link(); +public function embedYouTubeVideo(FreshRSS_Entry $entry): FreshRSS_Entry +{ + $link = $entry->link(); - if (preg_match('#^https?://www\.youtube\.com/watch\?v=|/videos/watch/[0-9a-f-]{36}$#', $link) !== 1) { - return $entry; - } + if ($this->isShort($link)) { + $link = $this->convertShortToWatch($link); + } - $this->loadConfigValues(); + if (preg_match('#^https?://www\.youtube\.com/watch\?v=|/videos/watch/[0-9a-f-]{36}$#', $link) !== 1) { + return $entry; + } - if (stripos($entry->content(), '