Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store entry source #276

Open
SorenDalsgaard opened this issue Mar 22, 2022 · 3 comments
Open

Store entry source #276

SorenDalsgaard opened this issue Mar 22, 2022 · 3 comments

Comments

@SorenDalsgaard
Copy link

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

@lemon24
Copy link
Owner

lemon24 commented Mar 22, 2022

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.

@lemon24
Copy link
Owner

lemon24 commented Mar 22, 2022

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

@lemon24 lemon24 changed the title Storing item elements from a feed item Store entry source Mar 22, 2022
@lemon24
Copy link
Owner

lemon24 commented Apr 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants