Tiny Tiny RSS

Tiny Tiny RSS est un agrégateur du flux RSS.

Tinytinyrsserg.png

https://fr.wikipedia.org/wiki/Agr%C3%A9gateur

https://tt-rss.org/


Dumping All the Feeds with Python[modifier]

from __future__ import print_function
import requests, json

def login (url, user, password):
    req = {
        'op': 'login',
        'user': user,
        'password': password
    }
    r = requests.post(url, data=json.dumps(req))
    return r.json()['content']['session_id']

def getFeeds (url, sid):
    req = {
        'sid': sid,
        'op': 'getFeeds',
        'cat_id': -3,
        'unread_only': False
    }
    r = requests.post(url, data=json.dumps(req))
    return r.json()['content']

def getHeadlines(url, sid, feed_id, show_content=False, include_attachments=False):
    req = {
        'sid': sid,
        'op': 'getHeadlines',
        'feed_id': feed_id,
        'show_content': show_content,
        'include_attachments': include_attachments
    }
    r = requests.post(url, data=json.dumps(req))
    return r.json()['content']

def getArticle (url, sid, article_id):
    req = {
        'sid': sid,
        'op': 'getArticle',
        'article_id': article_id
    }
    r = requests.post(url, data=json.dumps(req))
    return r.json()['content'][0]


if __name__ == "__main__":
    import argparse, sys

    ap = argparse.ArgumentParser("")
    ap.add_argument("--apiurl", default="http://localhost/opt/tt-rss/api/")
    ap.add_argument("--user", default="admin")
    ap.add_argument("--password", default="password")
    args = ap.parse_args()

    data = {}
    apiurl = args.apiurl
    sid = login(apiurl, args.user, args.password)
    feeds = data['feeds'] = getFeeds(apiurl, sid)
    data['articles'] = articles = []

    for f in feeds:
        print (u"Reading feed [{0}] {1}".format(f['id'], f['title']).encode("utf-8"), file=sys.stderr)
        for h in getHeadlines(apiurl, sid, f['id']):
            a = getArticle(apiurl, sid, h['id'])
            articles.append(a)
    print (json.dumps(data, indent=2))
Dernière modification effectuée le 13 juillet 2017.