include updatetime into entry

This commit is contained in:
Ronald Schaten 2013-03-18 20:54:00 +01:00
parent ebe598cd10
commit 9ca1f39628

View File

@ -3,7 +3,8 @@
from sqlalchemy import create_engine, Table, Column, Integer, Text, Boolean, DateTime, MetaData, ForeignKey, desc
from sqlalchemy.orm import sessionmaker, relation, backref
from sqlalchemy.ext.declarative import declarative_base
import datetime
from datetime import datetime
from time import mktime
import feedparser
import re
import sys
@ -78,9 +79,9 @@ class Feedinfo(Base):
self.version = parser.get('version')
self.encoding = parser.get('encoding')
self.bozo = parser.get('bozo')
self.lastfetched = datetime.datetime.now()
self.lastfetched = datetime.now()
if parser.get('status') == 200:
self.lastsuccessful = datetime.datetime.now()
self.lastsuccessful = datetime.now()
class Entry(Base):
@ -98,13 +99,14 @@ class Entry(Base):
fullpage = Column(Text)
readability = Column(Text)
updated = Column(DateTime)
firstfetched = Column(DateTime)
lastfetched = Column(DateTime)
sent = Column(DateTime)
def __init__(self, entry):
self.update(entry)
self.firstfetched = datetime.datetime.now()
self.firstfetched = datetime.now()
def __repr__(self):
return "<Entry('%s','%s','%s')>" % (self.title, "", "")
@ -116,13 +118,16 @@ class Entry(Base):
self.link = entry.get('link').encode('latin-1', 'replace')
if entry.has_key('summary'):
self.summary = entry.get('summary').encode('latin-1', 'replace')
if entry.has_key('content'):
self.content = entry.get('content').encode('latin-1', 'replace')
#if entry.has_key('content'):
#self.content = entry.get('content')
if entry.has_key('author'):
self.author = entry.get('author').encode('latin-1', 'replace')
if entry.has_key('updated_parsed'):
updated_parsed = entry.get('updated_parsed')
self.updated = datetime.fromtimestamp(mktime(updated_parsed))
if entry.has_key('enclosures'):
self.enclosures = entry.get('enclosures').encode('latin-1', 'replace')
self.lastfetched = datetime.datetime.now()
self.lastfetched = datetime.now()
def send_mail(sender, subject, body):
@ -153,7 +158,7 @@ def mail_daily_digest(session):
body = body + get_entry_text(entry)[0:100]
body = body + '\n'
body = body + 'link: [%s]\n\n' % entry.link
today = datetime.datetime.now()
today = datetime.now()
subject = '[atomstrom] %s (%s) - %d entries' % (today.strftime('%y%m%d'), today.strftime('%A'), count)
send_mail(sender, subject, body)