mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update economist.recipe
This commit is contained in:
parent
c851acf3de
commit
aa2ef871fb
@ -15,8 +15,6 @@ from calibre.web.feeds.news import BasicNewsRecipe
|
|||||||
from html5_parser import parse
|
from html5_parser import parse
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
# For past editions, set date to, for example, '2020-11-28'.
|
|
||||||
edition_date = None
|
|
||||||
use_archive = True
|
use_archive = True
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +69,7 @@ if use_archive:
|
|||||||
except Exception:
|
except Exception:
|
||||||
date = data['datePublished']
|
date = data['datePublished']
|
||||||
dt = datetime.fromisoformat(date[:-1]) + timedelta(seconds=time.timezone)
|
dt = datetime.fromisoformat(date[:-1]) + timedelta(seconds=time.timezone)
|
||||||
dt = dt.strftime('%b %d, %Y, %I:%M %p')
|
dt = dt.strftime('%b %d, %Y %I:%M %p')
|
||||||
if data['dateline'] is None:
|
if data['dateline'] is None:
|
||||||
E(article, 'p', dt, style='color: gray; font-size:small;')
|
E(article, 'p', dt, style='color: gray; font-size:small;')
|
||||||
else:
|
else:
|
||||||
@ -199,6 +197,13 @@ class Economist(BasicNewsRecipe):
|
|||||||
# downloaded with connection reset by peer (104) errors.
|
# downloaded with connection reset by peer (104) errors.
|
||||||
delay = 1
|
delay = 1
|
||||||
|
|
||||||
|
recipe_specific_options = {
|
||||||
|
'date': {
|
||||||
|
'short': 'The date of the edition to download (YYYY-MM-DD format)',
|
||||||
|
'long': 'For example, 2024-07-19\nThis seems to work only for a couple of past editions.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
needs_subscription = False
|
needs_subscription = False
|
||||||
|
|
||||||
def get_browser(self, *args, **kwargs):
|
def get_browser(self, *args, **kwargs):
|
||||||
@ -231,6 +236,7 @@ class Economist(BasicNewsRecipe):
|
|||||||
|
|
||||||
if use_archive:
|
if use_archive:
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
|
edition_date = self.recipe_specific_options.get('date')
|
||||||
# return self.economist_test_article()
|
# return self.economist_test_article()
|
||||||
# url = 'https://www.economist.com/weeklyedition/archive'
|
# url = 'https://www.economist.com/weeklyedition/archive'
|
||||||
query = {
|
query = {
|
||||||
@ -326,6 +332,7 @@ class Economist(BasicNewsRecipe):
|
|||||||
self.log.warn('Kindle Output profile being used, reducing image quality to keep file size below amazon email threshold')
|
self.log.warn('Kindle Output profile being used, reducing image quality to keep file size below amazon email threshold')
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
|
edition_date = self.recipe_specific_options.get('date')
|
||||||
# return self.economist_test_article()
|
# return self.economist_test_article()
|
||||||
if edition_date:
|
if edition_date:
|
||||||
url = 'https://www.economist.com/weeklyedition/' + edition_date
|
url = 'https://www.economist.com/weeklyedition/' + edition_date
|
||||||
|
Loading…
x
Reference in New Issue
Block a user