- Notifications
You must be signed in to change notification settings - Fork20
An RSS/Atom/JSONFeed reading + storing library for Django
License
xurble/django-feed-reader
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is a simple Django module to allow you subscribe to RSS (and other) feeds.
This app has no UI, it just reads and stores the feeds for you to use as you see fit.
This app builds on top of the FeedParser library to provide feed management, storage, scheduling etc.
- Consumes RSS, Atom and JSONFeed feeds.
- Parses feeds liberally to try and accomodate simple errors.
- Will attempt to bypass Cloudflare protection of feeds
- Supports enclosure (podcast) discovery
- Automatic feed scheduling based on frequency of updates
django-feed-reader is written in Python 3 and supports Django 2.2+
pip install django-feed-reader- Add
feedsto yourINSTALLED_APPS - Setup some values in
settings.pyso that your feed reader politely announces itself to servers - Set
FEEDS_USER_AGENTto the name and (optionally version) of your service e.g."ExampleFeeder/1.2" - Set
FEEDS_SERVERto preferred web address of your service so that feed hosts can locate you if required e.g.https://example.com
- Set
- Setup some values in
- Setup a mechanism to periodically refresh the feeds (see below)
FEEDS_VERIFY_HTTPS(Default True)- Older versions of this library did not verify https connections when fetching feeds.Set this to
Falseto revert to the old behaviour.
- Older versions of this library did not verify https connections when fetching feeds.Set this to
KEEP_OLD_ENCLOSURES(Default False)- Some feeds (particularly podcasts with Dynamic Ad Insertion) will change their enclosureurls between reads. By default, old enclosures are deleted and replaced with new ones.Set this to true, to retain old enclosures - they will have their
is_currentflagset toFalse
- Some feeds (particularly podcasts with Dynamic Ad Insertion) will change their enclosureurls between reads. By default, old enclosures are deleted and replaced with new ones.Set this to true, to retain old enclosures - they will have their
SAVE_JSON(Default False)- If set, Sources and Posts will store a JSON representation of the all the data retrievedfrom the feed so that uncommon or custom attributes can be retrieved. Caution - this willdramatically increase tha amount of space used in your database.
DRIPFEED_KEY(Default None)- If set to a valid Dripfeed API Key, then feeds that are blocked by Cloudflare willbe automatically polled viaDripfeed instead.
A feed is represented by aSource object which has (among other things) afeed_url.
To start reading a feed, simply create a newSource with the desiredfeed_url
Source objects havePost children which contain the content.
APost may haveEnclosure (or more) which is what podcasts use to send their audio.The app does not download enclosures, if you want to do that you will need to do that in your projectusing the url provided.
To conserve resources with large feed lists, the module will adjust how often it polls feedsbased on how often they are updated. The fastest it will poll a feed is every hour. Theslowest it will poll is every 24 hours.
Sources that don't get updated are polled progressively more slowly until the 24 hour limit isreached. When a feed changes, its polling frequency increases.
You will need to decided how and when to run the poller. When the poller runs, it checks allfeeds that are currently due. The ideal frequency to run it is every 5 - 10 minutes.
Set up a job that callspython manage.py refreshfeeds on your desired schedule.
Be careful to ensure you're running out of the correct directory and with the correct python environment.
Create a new celery task and schedule in your app (see the celery documentation for details). Yourtasks.py should look something like this:
from celery import shared_taskfrom feeds.utils import update_feeds@shared_taskdef get_those_feeds(): # the number is the max number of feeds to poll in one go update_feeds(30)
There are two ways to track the read/unread state of feeds depending on your needs.
If your usage is just for a single user, then there are helper methods on a Sourceto track your read state.
All posts come in unread. You can get the current number of unread posts fromSource.unread_count.
To get a ResultSet of all the unread posts from a feed callSource.get_unread_posts
To mark all posts on a fed as read callSource.mark_read
To get all of the posts in a feed regardless of read status, a page at a time callSource.get_paginated_posts which returns a tuple of (Posts, Paginator)
To allow multiple users to follow the same feed with individual read/unread status,create a newSubscription for that Source and User.
Subscription has the same helper methods for retrieving posts and marking read asSource.
You can also arrange feeds into a folder-like hierarchy using Subscriptions.Every Subscription has an optionalparent. Subscriptions with aNone parentare considered at the root level. By convention, Subscriptions that are acting as parentfolders should have aNonesource
Subscriptions have aname field which by convention should be a display name if it isa folder or the name of the Source it is tracking. However this can be set to anyvalue if you want to give a personally-meaningful name to a feed who's name is cryptic.
There are two helper methods in theutils module to help manage subscriptions as folders.get_subscription_list_for_user will return all Subscriptions for a User where theparent is None.get_unread_subscription_list_for_user will do the same but only returnsSubscriptions that are unread or that have unread children if they are a folder.
django-feed-reader has Dripfeed support built in. If a feed becomes blocked by Cloudflareit can be polled via Dripfeed instead. This requires aDripfeedaccount and API key.
For more details see thefull documentation.
About
An RSS/Atom/JSONFeed reading + storing library for Django
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.