From 5ddc0eebce9b7cae03f42c73d075422f1c87a85d Mon Sep 17 00:00:00 2001 From: NopeCharon <115794254+NopeCharon@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:26:32 +0530 Subject: [PATCH] [xExtension-YouTube] Stop FreshRSS from appending the enclosures again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since FreshRSS stores the enclosures as entry attributes, it renders them at display time: FreshRSS_Entry::content() appends the thumbnail and each enclosure whose URL is not found in the content. The extension builds its own content from $entry->content(), which already includes the rendered enclosures, and replaces them with the video player (and, when "Display the feeds content" is enabled, its own title, thumbnail and description). None of the original URLs are part of that new content, so FreshRSS then appended the whole enclosure again below the video: the thumbnail, a 💾 link to the old Flash URL and the description, shown twice in the second case. Add hidden references to the URLs of the thumbnail and of the enclosures at the end of the generated content, so FreshRSS knows they are already handled. This is the same approach ImageProxy uses with its data-xextension-imageproxy-original-src attributes. The entry attributes are left untouched, so the list thumbnail and the enclosures exposed through the APIs do not change. Bump the extension version to 1.4.1. Fixes #290 --- xExtension-YouTube/README.md | 3 +++ xExtension-YouTube/extension.php | 27 ++++++++++++++++++++++++++- xExtension-YouTube/metadata.json | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/xExtension-YouTube/README.md b/xExtension-YouTube/README.md index e89c55f6..6da2f57a 100644 --- a/xExtension-YouTube/README.md +++ b/xExtension-YouTube/README.md @@ -23,6 +23,9 @@ With activated Youtube extension: ## Changelog +1.4.1: +- Fixed the original thumbnail, description and enclosures of the feed being appended below the video + 1.4.0: - Added an option to disable embedding videos, e.g. to only use the channel icons and URL conversion diff --git a/xExtension-YouTube/extension.php b/xExtension-YouTube/extension.php index 052528fe..95b71a76 100644 --- a/xExtension-YouTube/extension.php +++ b/xExtension-YouTube/extension.php @@ -480,6 +480,31 @@ private function hasEnclosureStructure(string $content): bool { || stripos($content, 'enclosure-description') !== false; } + /** + * Returns hidden references to the URLs of the thumbnail and enclosures of an entry. + * When displaying an entry, FreshRSS appends the thumbnail and enclosures whose URL is not found in the content, + * which would show them again after the video player that replaces them. + */ + private function getEnclosureReferences(FreshRSS_Entry $entry): string { + $urls = []; + $thumbnail = $entry->thumbnail(searchEnclosures: false); + if ($thumbnail !== null) { + $urls[] = $thumbnail['url']; + } + foreach ($entry->enclosures() as $enclosure) { + $urls[] = $enclosure['url']; + } + + $references = ''; + foreach (array_unique($urls) as $url) { + if ($url === '') { + continue; + } + $references .= '
'; + } + return $references; + } + /** * Returns an HTML