Commit Graph
2 Commits
Author SHA1 Message Date
CaoMeiYouRenandAlexandre Alapetite 8e281292f9 RSS: emit <enclosure> for BitTorrent attachments (#9553)
* feat: add the <enclosure/> field to enhance compatibility with BitTorrent downloaders

Closes #6227

Changes proposed in this pull request:

- Emit an additional RSS 2.0 `<enclosure>` element for BitTorrent attachments in the
  generated RSS output (`p/api/query.php?...&f=rss` and the per-feed RSS view).
  The existing `<media:content>` output is unchanged.
- Emit it only for `application/x-bittorrent`, `magnet:` and `.torrent` URLs, and skip
  images / audio / video. Since 1.24 thumbnails are prepended to the enclosure list, a
  naive implementation would duplicate cover images (and podcast media) as attachments.
- Always set `type="application/x-bittorrent"`, and copy `length` when the feed provides it.
- Add unit tests in `tests/app/Views/rssViewTest.php`: torrent, magnet without type,
  image attachment skipped.

* fix(rss): emit <enclosure> only for BitTorrent attachments

The previous patch emitted <enclosure> for every enclosure. Since FreshRSS
1.24, thumbnails are prepended to the enclosures list, so cover images and
podcast audio were also duplicated as RSS attachments. Emit the tag only for
application/x-bittorrent, magnet: or .torrent URLs, and always set
type="application/x-bittorrent" so clients such as qBittorrent can use it.

Add three rssViewTest cases: torrent, magnet without type, image skipped.

* Improve regex

* Minor whitespace

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-11 21:02:30 +01:00
TowyTowyandClaude Opus 5 95842d81c1 Fix only the last <media:credit> being written to the RSS output (#9174)
The loop building the media credits assigned instead of appending, so an enclosure with several credits only kept the last one.

`app/views/index/rss.phtml` builds the `<media:credit>` elements for an enclosure in a loop, but assigns instead of appends:

```php
$mediaCredits = '';
foreach ($credits as $credit) {
    $mediaCredits = '<media:credit>' . $credit . '</media:credit>';
}
```

So an enclosure with three credits emits only the last one. Every iteration throws away what the previous one built.

This came in with #6272 ("Allow multiple authors on enclosures", which closed #5066). Parsing and display got multi-credit support, but FreshRSS's own generated RSS still passes on a single credit, so a downstream reader subscribing to a FreshRSS feed sees the same symptom #5066 described.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 22:49:52 +02:00