Increase delay for economist recipes and also dont have failure to fetch publication date be fatal

This commit is contained in:
Kovid Goyal 2024-11-01 16:59:32 +05:30
parent becebc1c0e
commit 871e4a5a1c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 4 deletions

View File

@ -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):

View File

@ -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):