This commit is contained in:
Kovid Goyal 2019-03-10 17:57:50 +05:30
parent 28145e76b0
commit a59d6a02fa
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -4,7 +4,7 @@ import re
from collections import defaultdict
from pprint import pformat
from calibre.utils.date import strptime
from calibre.utils.date import strptime, utcnow
from calibre.web.feeds.news import BasicNewsRecipe
DT_EPOCH = strptime('1970-01-01', '%Y-%m-%d', assume_utc=True)
@ -196,8 +196,10 @@ class LATimes(BasicNewsRecipe):
for article in articles:
mdate = date_rx.match(article['url'])
if mdate is not None:
article['timestamp'] = (strptime(mdate.group(
'date'),'%Y%m%d') - DT_EPOCH).total_seconds()
try:
article['timestamp'] = (strptime(mdate.group('date'),'%Y%m%d') - DT_EPOCH).total_seconds()
except Exception:
article['timestamp'] = (utcnow() - DT_EPOCH).total_seconds()
article['url'] = mdate.group(0)
self.log('Found: ', len(articles), ' articles.\n')
return articles