From 9d7f80d43a733636170cf6ef089ff0480dcf393c Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:13:00 +0530 Subject: [PATCH] Update Economist add delay --- recipes/economist.recipe | 21 +++++++++++---------- recipes/economist_free.recipe | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 6285119441..7470c58546 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -197,19 +197,10 @@ 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 = 0 if use_archive else 1 + delay = 1 needs_subscription = False - def __init__(self, *args, **kwargs): - BasicNewsRecipe.__init__(self, *args, **kwargs) - if self.output_profile.short_name.startswith('kindle'): - # Reduce image sizes to get file size below amazon's email - # sending threshold - self.web2disk_options.compress_news_images = True - self.web2disk_options.compress_news_images_auto_size = 5 - self.log.warn('Kindle Output profile being used, reducing image quality to keep file size below amazon email threshold') - def get_browser(self, *args, **kwargs): # Needed to bypass cloudflare kwargs['user_agent'] = 'common_words/based' @@ -298,6 +289,16 @@ class Economist(BasicNewsRecipe): return soup else: # Load articles from individual article pages {{{ + + def __init__(self, *args, **kwargs): + BasicNewsRecipe.__init__(self, *args, **kwargs) + if self.output_profile.short_name.startswith('kindle'): + # Reduce image sizes to get file size below amazon's email + # sending threshold + self.web2disk_options.compress_news_images = True + self.web2disk_options.compress_news_images_auto_size = 5 + self.log.warn('Kindle Output profile being used, reducing image quality to keep file size below amazon email threshold') + def parse_index(self): # return self.economist_test_article() if edition_date: diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 6285119441..7470c58546 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -197,19 +197,10 @@ 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 = 0 if use_archive else 1 + delay = 1 needs_subscription = False - def __init__(self, *args, **kwargs): - BasicNewsRecipe.__init__(self, *args, **kwargs) - if self.output_profile.short_name.startswith('kindle'): - # Reduce image sizes to get file size below amazon's email - # sending threshold - self.web2disk_options.compress_news_images = True - self.web2disk_options.compress_news_images_auto_size = 5 - self.log.warn('Kindle Output profile being used, reducing image quality to keep file size below amazon email threshold') - def get_browser(self, *args, **kwargs): # Needed to bypass cloudflare kwargs['user_agent'] = 'common_words/based' @@ -298,6 +289,16 @@ class Economist(BasicNewsRecipe): return soup else: # Load articles from individual article pages {{{ + + def __init__(self, *args, **kwargs): + BasicNewsRecipe.__init__(self, *args, **kwargs) + if self.output_profile.short_name.startswith('kindle'): + # Reduce image sizes to get file size below amazon's email + # sending threshold + self.web2disk_options.compress_news_images = True + self.web2disk_options.compress_news_images_auto_size = 5 + self.log.warn('Kindle Output profile being used, reducing image quality to keep file size below amazon email threshold') + def parse_index(self): # return self.economist_test_article() if edition_date: