News download: Handle more types of invalid timestamps in RSS feeds

This commit is contained in:
Kovid Goyal 2021-11-01 14:35:45 +05:30
parent 6ccbaac207
commit a553db9626
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -191,6 +191,14 @@ class Feed:
published = item.get(date_field, None)
if published is not None:
break
if not published:
from dateutil.parser import parse
for date_field in ('date', 'published', 'updated'):
try:
published = parse(item[date_field]).timetuple()
except Exception:
continue
break
if not published:
published = time.gmtime()
self.added_articles.append(id)