Skip to content

Commit

Permalink
Increase delay for economist recipes and also dont have failure to fe…
Browse files Browse the repository at this point in the history
…tch publication date be fatal
  • Loading branch information
kovidgoyal committed Nov 1, 2024
1 parent becebc1 commit 871e4a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions recipes/economist.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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):
Expand Down
8 changes: 6 additions & 2 deletions recipes/economist_free.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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):
Expand Down

0 comments on commit 871e4a5

Please sign in to comment.