obsoleted exception when parsing new entries
This commit is contained in:
parent
d3cb933521
commit
53c4665c85
20
atomstrom.py
20
atomstrom.py
@ -250,16 +250,17 @@ def fetch_full_page(link):
|
||||
return text.encode('latin-1', 'replace')
|
||||
|
||||
def process_feed_entry(session, feed, entry):
|
||||
#query = session.query(Entry).filter_by(feed_id=feed.id, title=entry.title.encode('latin-1', 'replace'))
|
||||
title = entry.title.encode('latin-1', 'replace')
|
||||
link = entry.link.encode('latin-1', 'replace')
|
||||
query = session.query(Entry).filter(Entry.feed_id==feed.id).filter(Entry.title==title).filter(Entry.link==link)
|
||||
try:
|
||||
thisentry = query.one()
|
||||
thisentry.update(entry)
|
||||
thisentry = session.query(Entry).\
|
||||
filter(Entry.feed_id == feed.id).\
|
||||
filter(Entry.title == entry.title).\
|
||||
filter(Entry.link == entry.link).\
|
||||
first()
|
||||
if thisentry:
|
||||
print ' entry already known <%s>' % entry.title
|
||||
thisentry.lastfetched = datetime.now()
|
||||
session.commit()
|
||||
return 0
|
||||
except Exception, e:
|
||||
else:
|
||||
print ' new entry <%s>' % entry.title
|
||||
thisentry = Entry(entry)
|
||||
if feed.resolveredirects:
|
||||
@ -283,8 +284,9 @@ def process_feed_entry(session, feed, entry):
|
||||
h2t.ignore_images = True
|
||||
summary = thisentry.summary.decode('latin-1')
|
||||
summary = h2t.handle(summary)
|
||||
thisentry.summary = summary.encode('latin-1', 'replace')
|
||||
thisentry.summary = summary.encode('latin-1')
|
||||
feed.entry.append(thisentry)
|
||||
session.commit()
|
||||
return 1
|
||||
|
||||
def fetch_single_feed(session, feed):
|
||||
|
Loading…
Reference in New Issue
Block a user