Opened 7 years ago

Closed 15 months ago

Last modified 12 months ago

#13110 closed New feature (fixed)

Allow multiple enclosures in Atom feeds

Reported by: Piaume Owned by: Unai Zalakain
Component: contrib.syndication Version: master
Severity: Normal Keywords: multiple, enclosures, atom, feed 1.9
Cc: kotenko@…, unai@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

For now, Feed.item_enclosure_url represents a single enclosure for an item. It should be nice to support many enclosures per item. Something like that:

class ExampleFeed(Feed):
    def item_enclosure_url(self, item):
        return [video.url for video in item.videos]

Change History (24)

comment:1 Changed 7 years ago by Eric Holscher

milestone: 1.21.3

Feature Request.

comment:2 Changed 7 years ago by Russell Keith-Magee

milestone: 1.3
Triage Stage: UnreviewedAccepted

comment:3 Changed 6 years ago by Jason Kotenko

Cc: kotenko@… added
Needs documentation: set
Needs tests: set
Owner: changed from nobody to Jason Kotenko
Status: newassigned

comment:4 Changed 6 years ago by Jason Kotenko

Triage Stage: AcceptedDesign decision needed

It appears that RSS only officially supports one enclosure per item {1}, and Atom supports multiple. Since RSS is the default feed, actually the use case presented in the bug report is invalid. The question then becomes, should we support multiple enclosures for Atom? As of now the enclosure is handled in the same general way in both types of feeds.

Changing to "Design Decision Needed" before I do anything else... Please let me know if that was the wrong thing to do in this situation, as I'm pretty new to the Django community.

{1} - http://www.rssboard.org/rss-profile#element-channel-item-enclosure

comment:5 Changed 6 years ago by Luke Plant

Type: New feature

comment:6 Changed 6 years ago by Luke Plant

Severity: Normal

comment:7 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset
Triage Stage: Design decision neededAccepted
UI/UX: unset

It should be possible to accept either a string or a list of string, and to validate that there's only one enclosure for RSS feeds.

comment:8 in reply to:  7 Changed 16 months ago by Unai Zalakain

Replying to aaugustin:

It should be possible to accept either a string or a list of string, and to validate that there's only one enclosure for RSS feeds.

Currently Feed builds the Enclosure from item_enclosure_url, item_enclosure_length and item_enclosure_mime_type. Accepting an optional list for one of them would mean accepting optional lists for the three of them and that would become quite a strange and cumbersome API.

Instead, I propose creating a item_enclosures attr/func (the same way all the other attr/funcs work) which, by default, returns a list with a single Enclosure in it. That enclosure would be built using the url, length and mime_type gotten from the corresponding attrs.

RSS feeds could then validate that item_enclosures is no longer than 1.

Last edited 16 months ago by Unai Zalakain (previous) (diff)

comment:9 Changed 16 months ago by Unai Zalakain

Cc: unai@… added
Has patch: set
Keywords: multiple enclosures atom feed added
Owner: changed from Jason Kotenko to Unai Zalakain
Version: 1.1master

comment:11 Changed 16 months ago by Unai Zalakain

I updated the commit with the proposed changes and opened a PR:
https://github.com/django/django/pull/5200

comment:12 Changed 15 months ago by Markus Holtermann

Patch needs improvement: set

comment:13 Changed 15 months ago by Unai Zalakain

Needs documentation: unset
Patch needs improvement: unset

Updated PR with docs.

comment:14 Changed 15 months ago by Unai Zalakain

Needs tests: unset

Basic tests added, PR updated, ready for review!

comment:15 Changed 15 months ago by Tim Graham

Patch needs improvement: set
Summary: Multiple enclosures per feed's itemAllow multiple enclosures in Atom feeds

I left comments for improvement on the pull request.

comment:16 Changed 15 months ago by Unai Zalakain

Patch needs improvement: unset

PR updated!

comment:17 Changed 15 months ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:18 Changed 15 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In aac2a2d:

Fixed #13110 -- Added support for multiple enclosures in Atom feeds.

The item_enclosures hook returns a list of Enclosure objects which is
then used by the feed builder. If the feed is a RSS feed, an exception is
raised as RSS feeds don't allow multiple enclosures per feed item.

The item_enclosures hook defaults to an empty list or, if the
item_enclosure_url hook is defined, to a list with a single Enclosure
built from the item_enclosure_url, item_enclosure_length, and
item_enclosure_mime_type hooks.

comment:19 Changed 15 months ago by Tim Graham

Has patch: unset
Keywords: 1.9 added
Resolution: fixed
Status: closednew
Triage Stage: Ready for checkinAccepted

Reopening per comments on the commit.

comment:20 Changed 15 months ago by Unai Zalakain

Has patch: set

Sorry about that…
New PR: https://github.com/django/django/pull/5315

comment:21 Changed 15 months ago by Unai Zalakain <unai@…>

In a4b80e24:

Refs #13110 -- Fixed mistakes in the new multiple enclosure feed tests

comment:22 Changed 15 months ago by Tim Graham

Resolution: fixed
Status: newclosed

comment:23 Changed 12 months ago by Tim Graham <timograham@…>

In 2ec23a3d:

Refs #13110 -- Fixed typo in Feed class reference.

comment:24 Changed 12 months ago by Tim Graham <timograham@…>

In 54295a95:

[1.9.x] Refs #13110 -- Fixed typo in Feed class reference.

Backport of 2ec23a3d41be2ba5df9f46b17e0a05eb1b051c41 from master

Note: See TracTickets for help on using tickets.
Back to Top