small performance improvement, error correction in handling of enclosures
This commit is contained in:
parent
2718e6502c
commit
777b8de0e3
@ -124,13 +124,9 @@ def process_feed_entry(session, feed, entry):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
def fetch_single_feed(session, feed):
|
def fetch_single_feed(session, feed):
|
||||||
print 'processing %s' % feed.url
|
print 'processing %d: %s' % (feed.id, feed.url)
|
||||||
thisfeedinfo = session.query(Feedinfo).\
|
|
||||||
filter(Feedinfo.feed_id==feed.id).\
|
|
||||||
first()
|
|
||||||
fetched = False
|
fetched = False
|
||||||
if thisfeedinfo:
|
if feed.feedinfo:
|
||||||
feed.feedinfo = thisfeedinfo
|
|
||||||
if (not feed.feedinfo.nextfetch) or (feed.feedinfo.nextfetch < datetime.now()):
|
if (not feed.feedinfo.nextfetch) or (feed.feedinfo.nextfetch < datetime.now()):
|
||||||
print 'feed known, fetching...'
|
print 'feed known, fetching...'
|
||||||
try:
|
try:
|
||||||
|
@ -69,11 +69,11 @@ class Entry(Base):
|
|||||||
if entry.has_key('enclosures') and len(entry.get('enclosures')) > 0:
|
if entry.has_key('enclosures') and len(entry.get('enclosures')) > 0:
|
||||||
enclosures = ''
|
enclosures = ''
|
||||||
for enclosure in entry.get('enclosures'):
|
for enclosure in entry.get('enclosures'):
|
||||||
url = enclosure['href']
|
|
||||||
length = size_human_readable(int(enclosure['length']))
|
|
||||||
if not enclosures == '':
|
if not enclosures == '':
|
||||||
enclosures += '\n'
|
enclosures += '\n'
|
||||||
enclosures += '%s (%s)' % (url, length)
|
enclosures += enclosure['href']
|
||||||
|
if enclosure.has_key('length'):
|
||||||
|
enclosures += ' (%s)' % size_human_readable(int(enclosure['length']))
|
||||||
self.enclosures = enclosures
|
self.enclosures = enclosures
|
||||||
if feed.resolveredirects:
|
if feed.resolveredirects:
|
||||||
print ' fetching final link <%s>' % entry.link
|
print ' fetching final link <%s>' % entry.link
|
||||||
|
Loading…
Reference in New Issue
Block a user