mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 14:04:12 +02:00
News download: Handle feeds that have entries with empty ids
This commit is contained in:
parent
6aa1b67d88
commit
fa67ceaeb2
1 changed files with 8 additions and 4 deletions
|
|
@ -152,11 +152,13 @@ def populate_from_preparsed_feed(self, title, articles, oldest_article=7,
|
|||
for item in articles:
|
||||
if len(self.articles) >= max_articles_per_feed:
|
||||
break
|
||||
id = item.get('id', 'internal id#'+str(self.id_counter))
|
||||
self.id_counter += 1
|
||||
id = item.get('id', None)
|
||||
if not id:
|
||||
id = 'internal id#%s'%self.id_counter
|
||||
if id in self.added_articles:
|
||||
return
|
||||
self.added_articles.append(id)
|
||||
self.id_counter += 1
|
||||
published = time.gmtime(item.get('timestamp', time.time()))
|
||||
title = item.get('title', _('Untitled article'))
|
||||
link = item.get('url', None)
|
||||
|
|
@ -176,13 +178,15 @@ def populate_from_preparsed_feed(self, title, articles, oldest_article=7,
|
|||
|
||||
|
||||
def parse_article(self, item):
|
||||
id = item.get('id', 'internal id#'+str(self.id_counter))
|
||||
self.id_counter += 1
|
||||
id = item.get('id', None)
|
||||
if not id:
|
||||
id = 'internal id#%s'%self.id_counter
|
||||
if id in self.added_articles:
|
||||
return
|
||||
published = item.get('date_parsed', time.gmtime())
|
||||
if not published:
|
||||
published = time.gmtime()
|
||||
self.id_counter += 1
|
||||
self.added_articles.append(id)
|
||||
|
||||
title = item.get('title', _('Untitled article'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue