From 1f9c67ce02acfd69b5934bba3d74ce6875b9809e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 17 Jun 2022 07:54:29 +0530 Subject: [PATCH] Fix #1979011 [Economist recipe not working](https://bugs.launchpad.net/calibre/+bug/1979011) --- recipes/economist.recipe | 10 ++++++---- recipes/economist_free.recipe | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 34bee60272..65508eb4c2 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -310,10 +310,12 @@ class Economist(BasicNewsRecipe): feeds_dict = defaultdict(list) for part in safe_dict(data, "props", "pageProps", "content", "hasPart", "parts"): - section = safe_dict(part, "print", "section", "headline") - title = safe_dict(part, "print", "headline") - url = safe_dict(part, "url", "canonical") - desc = safe_dict(part, "print", "description") + section = safe_dict(part, "print", "section", "headline") or '' + title = safe_dict(part, "print", "headline") or '' + url = safe_dict(part, "url", "canonical") or '' + if not section or not title or not url: + continue + desc = safe_dict(part, "print", "description") or '' feeds_dict[section].append({"title": title, "url": url, "description": desc}) self.log(' ', title, url, '\n ', desc) return [(section, articles) for section, articles in feeds_dict.items()] diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 34bee60272..65508eb4c2 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -310,10 +310,12 @@ class Economist(BasicNewsRecipe): feeds_dict = defaultdict(list) for part in safe_dict(data, "props", "pageProps", "content", "hasPart", "parts"): - section = safe_dict(part, "print", "section", "headline") - title = safe_dict(part, "print", "headline") - url = safe_dict(part, "url", "canonical") - desc = safe_dict(part, "print", "description") + section = safe_dict(part, "print", "section", "headline") or '' + title = safe_dict(part, "print", "headline") or '' + url = safe_dict(part, "url", "canonical") or '' + if not section or not title or not url: + continue + desc = safe_dict(part, "print", "description") or '' feeds_dict[section].append({"title": title, "url": url, "description": desc}) self.log(' ', title, url, '\n ', desc) return [(section, articles) for section, articles in feeds_dict.items()]