Opened 5 years ago

Last modified 13 hours ago

#13110 assigned New feature

Multiple enclosures per feed's item

Reported by: Piaume Owned by: unaizalakain
Component: contrib.syndication Version: master
Severity: Normal Keywords: multiple, enclosures, atom, feed
Cc: kotenko@…, unai@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes 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 (13)

comment:1 Changed 5 years ago by ericholscher

  • milestone changed from 1.2 to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Feature Request.

comment:2 Changed 5 years ago by russellm

  • milestone 1.3 deleted
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 years ago by jasonkotenko

  • Cc kotenko@… added
  • Needs documentation set
  • Needs tests set
  • Owner changed from nobody to jasonkotenko
  • Status changed from new to assigned

comment:4 Changed 5 years ago by jasonkotenko

  • Triage Stage changed from Accepted to Design 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 4 years ago by lukeplant

  • Type set to New feature

comment:6 Changed 4 years ago by lukeplant

  • Severity set to Normal

comment:7 follow-up: Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Triage Stage changed from Design decision needed to Accepted
  • 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 2 weeks ago by unaizalakain

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 2 weeks ago by unaizalakain (previous) (diff)

comment:9 Changed 2 weeks ago by unaizalakain

  • Cc unai@… added
  • Has patch set
  • Keywords multiple enclosures atom feed added
  • Owner changed from jasonkotenko to unaizalakain
  • Version changed from 1.1 to master

comment:11 Changed 7 days ago by unaizalakain

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

comment:12 Changed 4 days ago by MarkusH

  • Patch needs improvement set

comment:13 Changed 13 hours ago by unaizalakain

  • Needs documentation unset
  • Patch needs improvement unset

Updated PR with docs.

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