diff --git a/recipes/latimes.recipe b/recipes/latimes.recipe index 920252cc0f..0fd773ec22 100644 --- a/recipes/latimes.recipe +++ b/recipes/latimes.recipe @@ -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