Package: resyndicator
This documentation is best viewed onhttps://resyndicator.readthedocs.io/.PurposeThe Resyndicator is a Python 3 framework for aggregating data from various
sources into Atom feeds. If you have a list of a couple hundred data
sources – such as feeds, sitemaps, and Twitter users – and want to share the aggregate of those
entries between your various devices (computers, phones, etc.), your
colleagues, or even the visitors of your website, then that’s just what
the Resyndicator is for.It can obtain data from feeds, sitemaps, social media, and any other sources you implement.It allows for queries as sophisticated as SQLAlchemy allows to filter
your aggregate feed.It allows you to subclass the fetchers easily, so you can write fetchers for
endpoints as obscure as Adobe’s AMF.It keeps all entries in Postgres, so you have a backup.I’ve been using the Resyndicator for theEA Foundation,.impact,Saram,Derpy News, andFerret Go, and a marketing department of Logitech also indicated interest at one point.SetupI’ve created asample implementationof the Resyndicator framework to facilitate the setup process. You can fork it and adapt it for your purposes. (I’ve been following the convention of calling my implementations “soandsofeeder” – a word ending in “feeder” with no hyphen or space in between.) TheResyndicator is hosted on PyPI, so you can just install it through pip.One important file issamplefeeder/settings.pywith some general settings. For the defaults seeresyndicator/settings.py.The other issamplefeeder/resources.py.SettingsInsettings.py, you’ll in particular need to change your database credentials with something likeDATABASE ='postgresql://foo:bar@localhost/samplefeeder'(you may
need to create the database and grant access rights to the user). I haven’t tested it with anything other than Postgres.For
more options, seeresyndicator/settings.py.Note: You can create the database like so:create role samplefeeder with password 'samplefeeder' login;
create database samplefeeder with owner samplefeeder;My system automatically creates it with UTF-8 encoding, but some Debian systems package a version of
Postgres that uses some weird encoding by default. In that case make sure to inherit from the right template.postgres=# \l
                                                 List of databases
           Name           |     Owner      | Encoding  |   Collate   |    Ctype    |       Access privileges
--------------------------+----------------+-----------+-------------+-------------+-------------------------------
 postgres                 | postgres       | UTF8      | en_DK.UTF-8 | en_DK.UTF-8 |
 samplefeeder             | samplefeeder   | UTF8      | en_DK.UTF-8 | en_DK.UTF-8 |ResourcesInresources.py, you list the feeds and (eponymous) resyndicators
like so for example:from datetime import timedelta
from sqlalchemy.sql import or_
from resyndicator import settings
from resyndicator.models import Entry
from resyndicator.fetchers import (
    FeedFetcher, SitemapIndexFetcher, SitemapFetcher,
    TwitterFetcher, ContentFetcher)
from resyndicator.resyndicators import Resyndicator
from . import settings

CONTENT_FETCHERS = [
    ContentFetcher(past=settings.PAST, timeout=10)
]

RESYNDICATORS = [
    Resyndicator(
        title='Effective Altruism',
        past=PAST,
        query=or_(
            Entry.source_link.in_([
                'http://feeds.feedburner.com/TheGivewellBlog',
                'http://www.openphilanthropy.org/sitemap.xml',
            ])
        )
    )
]

FETCHERS = [
    FeedFetcher('http://feeds.feedburner.com/TheGivewellBlog',
                interval=10*60),
    SitemapFetcher('http://www.openphilanthropy.org/sitemap.xml',
                   defaults={'title': 'Open Phil Sitemap',
                             'author': 'Open Philanthropy Project'},
                   interval=30*60),
]

STREAMS = [
    TwitterFetcher(
        oauth_token=settings.OAUTH_TOKEN,
        oauth_secret=settings.OAUTH_SECRET,
        interval=5*60),
]Samplefeeder contains a working sampleresources.pythat you can adapt. It is missing the
sample TwitterFetcher so it does not expose the OAuth secret.For each resyndicator, you define a query and a title which will
determine its ID and thus its identity. If you change the title you
create a new, different feed. The query determines the entries of the feed and
is specified asSQLAlchemy where statements.To build your Samplefeeder fork, runmake.Running ItYou can check thesupervisord.confthat is includede with the Samplefeeder for sample invocations.Note: The Resyndicator requires Python 3 (and I haven’t tested it with versions older than Python 3.4) while Supervisor will only support Python 3 upon version 4.0, so you’ll need two different Pythons to run it this way. (But it’s no problem to run a Python 3 application through Supervisor.)[program:fetcher]
command = bin/resyndicator -s samplefeeder.settings fetchers
...

[program:content]
command = bin/resyndicator -s samplefeeder.settings content
...You can usebin/resyndicator-ssamplefeeder.settings fetchers--test-modeto instruct the Resyndicator to ignore the intervals and fetche all feeds immediately so you don’t have to wait to see if any of them malfunction.Serving the FeedsThe feeds are written to files in thewebroot/subdirectory. Point your Nginx or Varnish at this
directory to serve the feeds. An Nginx example:server {
    listen 80;
    listen [::]:80;
    server_name feeds.example.com;

    charset utf-8;
    keepalive_timeout 5;
    root /opt/samplefeeder/webroot/;
    access_log /var/log/nginx/feeds.access.log main;
}TestingYou can run use pytest to run the tests:maketo install the virtualenv with the Resyndicator and dependenciesbin/pip install pytestbin/py.test resyndicator