From 871e4a5a1c05e082ced2382dc3e1e3a3da4bcd0b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Nov 2024 16:59:32 +0530 Subject: [PATCH] Increase delay for economist recipes and also dont have failure to fetch publication date be fatal --- recipes/economist.recipe | 8 ++++++-- recipes/economist_free.recipe | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index cae5ada855..1a12a6256a 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -196,7 +196,7 @@ class Economist(BasicNewsRecipe): remove_attributes = ['data-reactid', 'width', 'height'] # economist.com has started throttling after about 60% of the total has # downloaded with connection reset by peer (104) errors. - delay = 2 + delay = 3 recipe_specific_options = { 'date': { @@ -223,7 +223,11 @@ class Economist(BasicNewsRecipe): edition_date = self.recipe_specific_options.get('date') if edition_date and isinstance(edition_date, str): return parse_only_date(edition_date, as_utc=False) - url = self.browser.open("https://www.economist.com/printedition").geturl() + try: + url = self.browser.open("https://www.economist.com/printedition").geturl() + except Exception as e: + self.log('Failed to fetch publication date with error: ' + str(e)) + return super().publication_date() return parse_only_date(url.split("/")[-1], as_utc=False) def economist_test_article(self): diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index cae5ada855..1a12a6256a 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -196,7 +196,7 @@ class Economist(BasicNewsRecipe): remove_attributes = ['data-reactid', 'width', 'height'] # economist.com has started throttling after about 60% of the total has # downloaded with connection reset by peer (104) errors. - delay = 2 + delay = 3 recipe_specific_options = { 'date': { @@ -223,7 +223,11 @@ class Economist(BasicNewsRecipe): edition_date = self.recipe_specific_options.get('date') if edition_date and isinstance(edition_date, str): return parse_only_date(edition_date, as_utc=False) - url = self.browser.open("https://www.economist.com/printedition").geturl() + try: + url = self.browser.open("https://www.economist.com/printedition").geturl() + except Exception as e: + self.log('Failed to fetch publication date with error: ' + str(e)) + return super().publication_date() return parse_only_date(url.split("/")[-1], as_utc=False) def economist_test_article(self):