fixed missing import
This commit is contained in:
parent
752794115e
commit
33da084705
12
atomstrom.py
12
atomstrom.py
@ -3,7 +3,7 @@
|
||||
|
||||
from models import Base, Feed, Feedinfo, Entry
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy import create_engine, desc
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from datetime import datetime, timedelta
|
||||
import feedparser
|
||||
@ -143,7 +143,7 @@ def process_feed_entry(session, feed, entry):
|
||||
session.commit()
|
||||
return 0
|
||||
else:
|
||||
print ' new entry <%s>' % entry.title
|
||||
# print ' new entry <%s>' % entry.title
|
||||
thisentry = Entry(entry)
|
||||
if feed.resolveredirects:
|
||||
print ' fetching final link <%s>' % entry.link
|
||||
@ -180,16 +180,24 @@ def fetch_single_feed(session, feed):
|
||||
nextfetch = (feed.feedinfo.lastfetched + timedelta(minutes=feed.frequency))
|
||||
if datetime.now() > nextfetch:
|
||||
print 'feed known, fetching...'
|
||||
try:
|
||||
parser = feedparser.parse(feed.url)
|
||||
fetched = True
|
||||
feed.feedinfo.update(parser)
|
||||
except:
|
||||
print 'ERROR parsing feed'
|
||||
print sys.exc_info()
|
||||
else:
|
||||
print 'not fetching before: %s' % nextfetch
|
||||
else:
|
||||
print 'feed seems to be new, fetching...'
|
||||
try:
|
||||
parser = feedparser.parse(feed.url)
|
||||
fetched = True
|
||||
feed.feedinfo = Feedinfo(parser)
|
||||
except:
|
||||
print 'ERROR parsing feed'
|
||||
print sys.exc_info()
|
||||
|
||||
if fetched:
|
||||
print 'processing feed entries:'
|
||||
|
Loading…
Reference in New Issue
Block a user