From 8b294a4b5ba7e9c7046677a48467ac79b8d42cfa Mon Sep 17 00:00:00 2001 From: Carl Chenet Date: Fri, 5 May 2017 18:59:50 +0200 Subject: [PATCH] manage feeds with missing id. fixes #13 --- feed2toot/main.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/feed2toot/main.py b/feed2toot/main.py index 2ddf17f..7869f0f 100755 --- a/feed2toot/main.py +++ b/feed2toot/main.py @@ -99,20 +99,35 @@ class Main(object): # cache the ids of last rss feeds if not clioptions.all: for i in entries: - if 'id' in i and i['id'] not in cache.getdeque(): - totweet.append(i) + 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) else: totweet = entries for entry in totweet: - if 'id' not in entry: - # malformed feed entry, skip - continue - logging.debug('found feed entry {entryid}'.format(entryid=entry['id'])) - - rss = { - 'id': entry['id'], - } + if 'id' in entry: + logging.debug('found feed entry {entryid}'.format(entryid=entry['id'])) + rss = { + '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 # lets see if the rss feed has hashtag