reader
reader copied to clipboard
Store entry source
Hi
First of thanks for building this great tool.
I am having a small issue with understanding how to store elements from a feed item.
For this feed https://www.newsdesk.lexisnexis.com/feed/aeb9dae6799dcbd4.rss
I am interested in storing the source
element.
How could I store this for each entry in the feed? Thanks
Hi, thanks for reaching out!
source
doesn't seems to be stored at the moment; reader started out using a subset of the stuff feedparser exposes, and I kept adding more and more fields as I needed them.
I think source
should be relatively easy to add. I can't promise I can get to it anytime soon, but I will prioritize reviewing a pull request for it.
Some notes on implementing this.
The RSS source
just points to the original feed:
<source url="http://example.com/feed.xml">Some Feed</source>
The Atom source
is way more complicated, containing a subset of the feed
elements.
feedparser represents the RSS source element like this:
{'href': 'http://example.com/feed.xml', 'title': 'Some Feed'}
Note the href
is not a documented attribute of the feedparser entries[i].source
(but is accessible as source.url
, because source is a FeedParserDict). The Atom equivalent of href
would then be link[rel=self]
, and the reader equivalent url
(per #153, and for similarity with Feed).
It should be pretty safe to make Entry.source have a subset of the Feed attributes:
class Entry:
...
source: Optional[EntrySource]
class EntrySource:
url: str # RSS href/url; Atom link[rel=self]
updated: Optional[datetime] = None
title: Optional[str] = None
link: Optional[str] = None
author: Optional[str] = None
subtitle: Optional[str] = None
2024 implementation notes:
- We probably want change_feed_url() to set Entry.source with the details of the old feed, if the entry does not already have a source (in this case, Entry.source.url would be the same as Entry.original_feed_url).
- However, if the entry in the parsed feed has a source, that should always overwrite Entry.source.