mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1819321 [news download for LA Times fails](https://bugs.launchpad.net/calibre/+bug/1819321)
This commit is contained in:
parent
28145e76b0
commit
a59d6a02fa
@ -4,7 +4,7 @@ import re
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
|
||||||
from calibre.utils.date import strptime
|
from calibre.utils.date import strptime, utcnow
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
DT_EPOCH = strptime('1970-01-01', '%Y-%m-%d', assume_utc=True)
|
DT_EPOCH = strptime('1970-01-01', '%Y-%m-%d', assume_utc=True)
|
||||||
@ -196,8 +196,10 @@ class LATimes(BasicNewsRecipe):
|
|||||||
for article in articles:
|
for article in articles:
|
||||||
mdate = date_rx.match(article['url'])
|
mdate = date_rx.match(article['url'])
|
||||||
if mdate is not None:
|
if mdate is not None:
|
||||||
article['timestamp'] = (strptime(mdate.group(
|
try:
|
||||||
'date'),'%Y%m%d') - DT_EPOCH).total_seconds()
|
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)
|
article['url'] = mdate.group(0)
|
||||||
self.log('Found: ', len(articles), ' articles.\n')
|
self.log('Found: ', len(articles), ' articles.\n')
|
||||||
return articles
|
return articles
|
||||||
|
Loading…
x
Reference in New Issue
Block a user