1
0
mirror of https://github.com/sjlongland/tornado-news.git synced 2025-09-13 10:03:14 +10:00

Handle feeds with entries that lack IDs

The Australian Bureau of Meteorology is one such feed.
http://media.bom.gov.au/rss/

Instead, we'll generate one using the SHA1 hash of the link.
This commit is contained in:
Stuart Longland 2016-07-14 20:08:20 +10:00
parent e107cee304
commit b353f70cfa
Signed by: stuartl
GPG Key ID: 4DFA191410BDE3B7

View File

@ -75,8 +75,14 @@ class FeedEntry(object):
else:
content = entry['summary']
try:
entry_id = entry['id']
except KeyError:
# Aust. Bureau of Meteorology doesn't have an 'id'
entry_id = sha1(entry['link']).hexdigest()
return cls(
source, entry['id'], entry['link'], entry['title'],
source, entry_id, entry['link'], entry['title'],
entry.get('author') or 'Anonymous',
timegm(entry.get('updated_parsed') or \
entry['published_parsed']),