Merge pull request #2718 from return42/fix-publishedDate

[fix] publishedDate: don't try to get date from empty string or None
This commit is contained in:
Noémi Ványi 2021-04-04 23:00:22 +02:00 committed by GitHub
commit ba90c5a2e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -650,7 +650,7 @@ def search():
result['pretty_url'] = prettify_url(result['url'])
# TODO, check if timezone is calculated right
if 'publishedDate' in result:
if result.get('publishedDate'): # do not try to get a date from an empty string or a None type
try: # test if publishedDate >= 1900 (datetime module bug)
result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S%z')
except ValueError: