From 9e3171e3a69705ff7c04299377d47e9d0ba26f7e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 12 May 2017 22:08:52 +0530 Subject: [PATCH] Economist recipe reduce image quality to keep file size below amazon's email threshold when the output profile is set to a kindle profile Fix #662 (Updating for reduced image sizes) --- recipes/economist.recipe | 9 +++++++++ recipes/economist_free.recipe | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 55d3421297..ce75d8b437 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -91,6 +91,15 @@ class Economist(BasicNewsRecipe): 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): br = BasicNewsRecipe.get_browser(self) # Add a cookie indicating we have accepted Economist's cookie diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 55d3421297..ce75d8b437 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -91,6 +91,15 @@ class Economist(BasicNewsRecipe): 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): br = BasicNewsRecipe.get_browser(self) # Add a cookie indicating we have accepted Economist's cookie