implemented listing of feeds
This commit is contained in:
parent
91d1cf552e
commit
372a43f85b
25
atomstrom.py
25
atomstrom.py
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from models import Base, Feed, Feedinfo, Entry
|
from models import Base, Feed, Feedinfo, Entry
|
||||||
|
|
||||||
from sqlalchemy import create_engine, desc
|
from sqlalchemy import create_engine, desc, func
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from ddate import ddate
|
from ddate import ddate
|
||||||
@ -214,9 +214,28 @@ def fetch_single_feed(session, feed):
|
|||||||
session.commit()
|
session.commit()
|
||||||
print 'updated %d of %d entries' % (entries_new, entries_total)
|
print 'updated %d of %d entries' % (entries_new, entries_total)
|
||||||
|
|
||||||
|
def list_all_feeds(session):
|
||||||
|
allfeeds = session.query(Feed).\
|
||||||
|
order_by(Feed.id)
|
||||||
|
totalfeeds = 0
|
||||||
|
totalentries = 0
|
||||||
|
for feed in allfeeds:
|
||||||
|
id = feed.id
|
||||||
|
title = feed.feedinfo.title
|
||||||
|
entries = len(feed.entry)
|
||||||
|
last = feed.feedinfo.lastsuccessful
|
||||||
|
url = feed.url
|
||||||
|
print '%3d %s (%d entries, last fetched %s)\n %s' % (id, title, entries, last, url)
|
||||||
|
totalfeeds += 1
|
||||||
|
totalentries += entries
|
||||||
|
print 'TOTAL: %d entries in %d feeds.' % (totalentries, totalfeeds)
|
||||||
|
|
||||||
def fetch_all_feeds(session):
|
def fetch_all_feeds(session):
|
||||||
print 'fetching all feeds...'
|
print 'fetching all feeds...'
|
||||||
for feed in session.query(Feed).filter_by(enabled=1).order_by(Feed.id):
|
allfeeds = session.query(Feed).\
|
||||||
|
filter_by(enabled=1).\
|
||||||
|
order_by(Feed.id)
|
||||||
|
for feed in allfeeds:
|
||||||
fetch_single_feed(session, feed)
|
fetch_single_feed(session, feed)
|
||||||
print
|
print
|
||||||
|
|
||||||
@ -265,7 +284,7 @@ if __name__ == '__main__':
|
|||||||
prefix = config.get('email', 'prefix_digest')
|
prefix = config.get('email', 'prefix_digest')
|
||||||
mail_daily_digest(session, sender, receiver, prefix)
|
mail_daily_digest(session, sender, receiver, prefix)
|
||||||
if args.list:
|
if args.list:
|
||||||
print 'TODO: list all configured feeds'
|
list_all_feeds(session)
|
||||||
if args.delete:
|
if args.delete:
|
||||||
print 'TODO: delete feed <%d>' % args.delete
|
print 'TODO: delete feed <%d>' % args.delete
|
||||||
if args.reset:
|
if args.reset:
|
||||||
|
Loading…
Reference in New Issue
Block a user