From f42727f558749a57046f2582efeb98b375983c85 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Apr 2025 07:12:16 +0530 Subject: [PATCH] Fix #2106187 [Download of The Economist fails v8.1.1](https://bugs.launchpad.net/calibre/+bug/2106187) --- recipes/economist.recipe | 5 ++++- recipes/economist_free.recipe | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 542dc170cb..74ef9c0e5f 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -376,7 +376,10 @@ class Economist(BasicNewsRecipe): # data = json.loads(raw)['data']['section'] # else: # data = json.loads(raw)['data']['canonical']['hasPart']['parts'][0] - data = json.loads(raw)['data']['section'] + try: + data = json.loads(raw)['data']['section'] + except KeyError: + data = json.loads(raw)['data']['canonical']['hasPart']['parts'][0] dt = datetime.fromisoformat(data['datePublished'][:-1]) + timedelta(seconds=time.timezone) dt = dt.strftime('%b %d, %Y') self.timefmt = ' [' + dt + ']' diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 542dc170cb..74ef9c0e5f 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -376,7 +376,10 @@ class Economist(BasicNewsRecipe): # data = json.loads(raw)['data']['section'] # else: # data = json.loads(raw)['data']['canonical']['hasPart']['parts'][0] - data = json.loads(raw)['data']['section'] + try: + data = json.loads(raw)['data']['section'] + except KeyError: + data = json.loads(raw)['data']['canonical']['hasPart']['parts'][0] dt = datetime.fromisoformat(data['datePublished'][:-1]) + timedelta(seconds=time.timezone) dt = dt.strftime('%b %d, %Y') self.timefmt = ' [' + dt + ']'