Skip to content

Commit 780a8f6

Browse files
authored
Merge pull request #38 from xurble/subscriptions
Subscriptions
2 parents 4230005 + 6233b15 commit 780a8f6

File tree

11 files changed

+468
-178
lines changed

11 files changed

+468
-178
lines changed

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
### 2.0.0
3-
- Feature: Convenience method to get unread posts when running single user
3+
- Feature: Convenience method to get unread posts / mark read when running single user
4+
- Feature: Convenience methods on Subscription to get read and unread posts and mark read
45
- Feature: Store (optionally) the full parsed feed and items as JSON to allow full access to all features of the feed
56
- Feature: Keeps old enclosures when url changes
67
- Feature: Automatically manage subscription count for feeds

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ Welcome to django-feed-reader's documentation!
1010
:maxdepth: 2
1111
:caption: Contents:
1212

13+
modules/overview.rst
1314
modules/about.rst
15+
modules/commands.rst
1416
modules/models.rst
1517
modules/utils.rst
1618

docs/modules/commands.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Commands
2+
========

docs/modules/overview.rst

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
Django Feed Reader
2+
==================
3+
4+
This is a simple Django module to allow you subscribe to RSS (and other) feeds.
5+
6+
This app has no UI, it just reads and stores the feeds for you to use as you see fit.
7+
8+
This app builds on top of the FeedParser library to provide feed management, storage, scheduling etc.
9+
10+
Features
11+
--------
12+
13+
* Consumes RSS, Atom and JSONFeed feeds.
14+
* Parses feeds liberally to try and accomodate simple errors.
15+
* Will attempt to bypass Cloudflare protection of feeds
16+
* Supports enclosure (podcast) discovery
17+
* Automatic feed scheduling based on frequency of updates
18+
19+
20+
Installation
21+
------------
22+
23+
``django-feed-reader`` is written in Python 3 and supports Django 2.2+
24+
25+
- ``pip install django-feed-reader``
26+
- Add ``feeds`` to your ``INSTALLED_APPS``
27+
- Setup some values in ``settings.py`` so that your feed reader politely announces itself to servers
28+
- Set ``FEEDS_USER_AGENT`` to the name and (optionally version) of your service e.g. ``"ExampleFeeder/1.2"``
29+
- Set ``FEEDS_SERVER`` to preferred web address of your service so that feed hosts can locate you if required e.g. ``https://example.com``
30+
- Setup a mechanism to periodically refresh the feeds (see below)
31+
32+
Basic Models
33+
------------
34+
35+
A feed is represented by a ``Source`` object which has (among other things) a ``feed_url``.
36+
37+
To start reading a feed, simply create a new ``Source`` with the desired ``feed_url``
38+
39+
``Sources`` have ``Posts`` a which contain the content.
40+
41+
``Posts`` may have ``Enclosures`` s 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 it in your project using the url provided.
42+
43+
44+
Refreshing feeds
45+
----------------
46+
47+
To conserve resources with large feed lists, the module will adjust how often it polls feeds based on how often they are updated. The fastest it will poll a feed is every hour. The slowest it will poll is every 24 hours.
48+
49+
Sources that don't get updated are polled progressively more slowly until the 24 hour limit is reached. When a feed changes, its polling frequency increases.
50+
51+
You will need to decided how and when to run the poller. When the poller runs, it checks all feeds that are currently due. The ideal frequency to run it is every 5 - 10 minutes.
52+
53+
Polling with cron
54+
-----------------
55+
56+
Set up a job that calls ``python manage.py refreshfeeds`` on your desired schedule.
57+
58+
Be careful to ensure you're running out of the correct directory and with the correct python environment.
59+
60+
Polling with celery
61+
-------------------
62+
63+
Create a new celery task and schedule in your app (see the celery documentation for details). Your ``tasks.py`` should look something like this:
64+
65+
::
66+
67+
from celery import shared_task
68+
from feeds.utils import update_feeds
69+
70+
@shared_task
71+
def get_those_feeds():
72+
73+
# the number is the max number of feeds to poll in one go
74+
update_feeds(30)
75+
76+
77+
Tracking read/unread state of feeds
78+
-----------------------------------
79+
80+
There are two ways to track the read/unread state of feeds depending on your needs.
81+
82+
83+
Single User Installations
84+
^^^^^^^^^^^^^^^^^^^^^^^^^
85+
86+
If your usage is just for a single user, then there are helper methods on a ``Source``
87+
to track your read state.
88+
89+
All posts come in unread. You can get the current number of unread posts from
90+
``Source.unread_count``.
91+
92+
To get all the unread posts from a feed in chronological order
93+
94+
95+
96+
Dealing with Cloudflare
97+
-----------------------
98+
99+
Depending on where you run your server, you may run into problems with Cloudflare's web captcha. Plenty of sites out there set up their Cloudflare to have default security on their RSS feed and this can block server-side RSS readers.
100+
101+
It's a huge pain and affects lots of self-hosted RSS readers. Seriously, Google it.
102+
103+
``django-feed-reader`` will do it's utmost to get these feeds anyway through the judicious use of public proxy servers, but is haphazard and you cannot rely on the scheduling of such feeds.
104+
105+
Feeds blocked by Cloudflare will have the ``is_cloudflare`` flag set on their ``Source`` and will update on a best-efforts basis.

docs/modules/utils.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Utils
22
=====
33

4+
This module contains useful utility functions for manipulating your feeds.
5+
46
.. automodule:: feeds.utils
57
:members:
68
:undoc-members:

0 commit comments

Comments
 (0)