From aa2ef871fb6e82656e82129e6d31674956f6e8e8 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:52:03 +0530 Subject: [PATCH 1/3] Update economist.recipe --- recipes/economist.recipe | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index cf47a8fda1..2941338f4f 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -15,8 +15,6 @@ from calibre.web.feeds.news import BasicNewsRecipe from html5_parser import parse from lxml import etree -# For past editions, set date to, for example, '2020-11-28'. -edition_date = None use_archive = True @@ -71,7 +69,7 @@ if use_archive: except Exception: date = data['datePublished'] 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: E(article, 'p', dt, style='color: gray; font-size:small;') else: @@ -199,6 +197,13 @@ class Economist(BasicNewsRecipe): # downloaded with connection reset by peer (104) errors. 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 def get_browser(self, *args, **kwargs): @@ -231,6 +236,7 @@ class Economist(BasicNewsRecipe): if use_archive: def parse_index(self): + edition_date = self.recipe_specific_options.get('date') # return self.economist_test_article() # url = 'https://www.economist.com/weeklyedition/archive' 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') def parse_index(self): + edition_date = self.recipe_specific_options.get('date') # return self.economist_test_article() if edition_date: url = 'https://www.economist.com/weeklyedition/' + edition_date From 6218a97320d31abfef989f86f96eea998cb6a921 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:55:09 +0530 Subject: [PATCH 2/3] ... --- recipes/economist.recipe | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 2941338f4f..15cb026a6c 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -266,6 +266,7 @@ class Economist(BasicNewsRecipe): return self.economist_return_index(ans) def economist_parse_index(self, raw): + edition_date = self.recipe_specific_options.get('date') if edition_date: data = json.loads(raw)['data']['section'] else: From eafdc3c7a94dae84a87d6ba9baf411fcb07c1cde Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:58:19 +0530 Subject: [PATCH 3/3] ... --- recipes/economist.recipe | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 15cb026a6c..3ecf3082f5 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -214,6 +214,7 @@ class Economist(BasicNewsRecipe): return br def publication_date(self): + edition_date = self.recipe_specific_options.get('date') if edition_date: return parse_only_date(edition_date, as_utc=False) url = self.browser.open("https://www.economist.com/printedition").geturl() @@ -424,6 +425,7 @@ class Economist(BasicNewsRecipe): return raw def parse_index_from_printedition(self): # return self.economist_test_article() + edition_date = self.recipe_specific_options.get('date') if edition_date: url = 'https://www.economist.com/weeklyedition/' + edition_date self.timefmt = ' [' + edition_date + ']'