Skip to content

[xExtension-YouTube] Stop FreshRSS from appending the enclosures again - #565

Merged
Alkarex merged 1 commit into
FreshRSS:mainfrom
NopeCharon:youtube-enclosure-duplicates
Oct 28, 2026
Merged

Alkarex merged 1 commit into
FreshRSS:mainfrom
NopeCharon:youtube-enclosure-duplicates

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Summary

  • FreshRSS renders the enclosures at display time: FreshRSS_Entry::content() appends the thumbnail and each enclosure whose URL is not found in the content. The extension builds its content from $entry->content(), which already includes the rendered enclosures, and replaces them with the video player (plus its own title, thumbnail and description when Display the feeds content is enabled). None of the original URLs are in that new content, so FreshRSS appended the whole enclosure again below the video
  • add hidden references to the URLs of the thumbnail and the enclosures at the end of the generated content, so FreshRSS_Entry::content() knows they are already handled. This is the approach suggested in the issue ([Bug] Enclosures whose URL has been changed by plugins are displayed twice FreshRSS#7240 (comment)) and the one ImageProxy already uses with data-xextension-imageproxy-original-src
  • the entry attributes are not modified, so the thumbnail in the article list and the enclosures exposed through the APIs stay the same
  • bump the extension version to 1.4.1 and add a changelog entry

Fixes #290

Validation

End-to-end with FreshRSS edge (PHP 8.3): parse a feed with FreshRSS_SimplePieCustom + FreshRSS_Feed::loadEntries(), run embedYouTubeVideo(), then render $entry->content(true) like index/normal.phtml:

  • YouTube feed (one media:group with media:content, media:thumbnail, media:description)
    • on main, Display the feeds content disabled: iframe, then <figure class="enclosure"> with the thumbnail, a 💾 link to https://www.youtube.com/v/…?version=3 and the description
    • on main, Display the feeds content enabled: the extension's iframe and description, then the same <figure> again (description shown twice)
    • with this change: only the iframe (and, when enabled, the extension's own description); $entry->thumbnail() is unchanged
  • PeerTube feed with a /videos/watch/<uuid> link (a media:thumbnail and two video enclosures): on main the thumbnail and two <video> players were appended below the iframe, with this change none

Also phpcs and phpstan (with ../FreshRSS).

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 FreshRSS#290
@Alkarex
Alkarex merged commit 0d8c8ec into FreshRSS:main Oct 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[xExtension-YouTube] content replacement broken

2 participants