implemented listing of feeds

This commit is contained in:
Ronald Schaten 2013-04-03 23:31:57 +02:00
parent 91d1cf552e
commit 372a43f85b

View File

@ -3,7 +3,7 @@
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 datetime import datetime
from ddate import ddate
@ -214,9 +214,28 @@ def fetch_single_feed(session, feed):
session.commit()
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):
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)
print
@ -265,7 +284,7 @@ if __name__ == '__main__':
prefix = config.get('email', 'prefix_digest')
mail_daily_digest(session, sender, receiver, prefix)
if args.list:
print 'TODO: list all configured feeds'
list_all_feeds(session)
if args.delete:
print 'TODO: delete feed <%d>' % args.delete
if args.reset: