manage feeds with missing id. fixes #13

This commit is contained in:
Carl Chenet 2017-05-05 18:59:50 +02:00
parent 2ca649d22e
commit 8b294a4b5b

View File

@ -99,20 +99,35 @@ class Main(object):
# cache the ids of last rss feeds # cache the ids of last rss feeds
if not clioptions.all: if not clioptions.all:
for i in entries: for i in entries:
if 'id' in i and i['id'] not in cache.getdeque(): if 'id' in i:
if i['id'] not in cache.getdeque():
totweet.append(i)
elif 'guid' in i:
if i['guid'] not in cache.getdeque():
totweet.append(i)
else:
# if id or guid not in the entry, use link
if i['link'] not in cache.getdeque():
totweet.append(i) totweet.append(i)
else: else:
totweet = entries totweet = entries
for entry in totweet: for entry in totweet:
if 'id' not in entry: if 'id' in entry:
# malformed feed entry, skip
continue
logging.debug('found feed entry {entryid}'.format(entryid=entry['id'])) logging.debug('found feed entry {entryid}'.format(entryid=entry['id']))
rss = { rss = {
'id': entry['id'], 'id': entry['id'],
} }
elif 'guid' in entry:
logging.debug('found feed entry {entryid}'.format(entryid=entry['guid']))
rss = {
'id': entry['guid'],
}
else:
logging.debug('found feed entry {entryid}'.format(entryid=entry['link']))
rss = {
'id': entry['link'],
}
severalwordsinhashtag = False severalwordsinhashtag = False
# lets see if the rss feed has hashtag # lets see if the rss feed has hashtag