From 7336a7a91dabf5699a5cb454208129a6379de8e6 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Thu, 3 Apr 2025 21:51:20 +0530 Subject: [PATCH 1/5] Update Economist --- recipes/economist.recipe | 17 ++++++++++------- recipes/economist_free.recipe | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index ad37e0414b..6d2fcb33f4 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -252,7 +252,7 @@ class Economist(BasicNewsRecipe): # downloaded with connection reset by peer (104) errors. delay = 3 - from_archive = True + from_archive = False recipe_specific_options = { 'date': { @@ -289,7 +289,13 @@ class Economist(BasicNewsRecipe): else: kwargs['user_agent'] = 'TheEconomist-Lamarr-android' br = BasicNewsRecipe.get_browser(self, *args, **kwargs) - br.addheaders += [('x-request-id', str(uuid4()))] + br.addheaders += [ + ('accept', '*/*'), + ('content-type', 'application/json'), + ('apollographql-client-name', 'mobile-app-apollo'), + ('apollographql-client-version', '3.50.0'), + ('x-request-id', str(uuid4())), + ] return br def publication_date(self): @@ -320,10 +326,7 @@ class Economist(BasicNewsRecipe): def get_content_id(self, ed_date): id_query = { - 'query': 'query EditionsQuery($from:Int$size:Int$ref:String!){section:canonical(ref:$ref){...EditionFragment __typename}}' - 'fragment EditionFragment on Content{hasPart(from:$from size:$size sort:"datePublished:desc")' - '{total parts{id datePublished image{...ImageCoverFragment __typename}__typename}__typename}__typename}' - 'fragment ImageCoverFragment on Media{cover{headline width height url{canonical __typename}regionsAllowed __typename}__typename}', + 'query': 'query EditionsQuery($from:Int$size:Int$ref:String!){section:canonical(ref:$ref){...EditionFragment __typename}}fragment EditionFragment on Content{hasPart(from:$from size:$size sort:"datePublished:desc"){total parts{id datePublished image{...ImageCoverFragment __typename}__typename}__typename}__typename}fragment ImageCoverFragment on Media{cover{headline width height url{canonical __typename}regionsAllowed __typename}__typename}', # noqa: E501 'operationName': 'EditionsQuery', 'variables':'{"from":0,"size":24,"ref":"/content/d06tg8j85rifiq3oo544c6b9j61dno2n"}', } @@ -350,7 +353,7 @@ class Economist(BasicNewsRecipe): content_id = self.get_content_id(edition_date) if content_id: query = { - 'query': 'query SpecificWeeklyEditionQuery($path:String!){section:canonical(ref:$path){...WeeklyEditionFragment __typename}}fragment WeeklyEditionFragment on Content{id type datePublished image{...ImageCoverFragment __typename}url{canonical __typename}hasPart(size:100 sort:"publication.context.position"){parts{...ArticleFragment __typename}__typename}__typename}fragment ArticleFragment on Content{articleSection{internal{id title:headline __typename}__typename}audio{main{id duration(format:"seconds")source:channel{id __typename}url{canonical __typename}__typename}__typename}byline dateline dateModified datePublished flyTitle:subheadline id image{...ImageInlineFragment ...ImageMainFragment ...ImagePromoFragment __typename}print{title:headline flyTitle:subheadline rubric:description section{id title:headline __typename}__typename}publication{id tegID title:headline flyTitle:subheadline datePublished regionsAllowed url{canonical __typename}__typename}rubric:description source:channel{id __typename}tegID text(format:"json")title:headline type url{canonical __typename}__typename}fragment ImageInlineFragment on Media{inline{url{canonical __typename}width height __typename}__typename}fragment ImageMainFragment on Media{main{url{canonical __typename}width height __typename}__typename}fragment ImagePromoFragment on Media{promo{url{canonical __typename}id width height __typename}__typename}fragment ImageCoverFragment on Media{cover{headline width height url{canonical __typename}regionsAllowed __typename}__typename}', # noqa: E501 + 'query': 'query SpecificWeeklyEditionQuery($path:String!){section:canonical(ref:$path){...WeeklyEditionFragment __typename}}fragment WeeklyEditionFragment on Content{id type datePublished image{...ImageCoverFragment __typename}url{canonical __typename}hasPart(size:100 sort:"publication.context.position"){parts{...ArticleFragment __typename}__typename}__typename}fragment ArticleFragment on Content{ad{grapeshot{channels{name __typename}__typename}__typename}articleSection{internal{id title:headline __typename}__typename}audio{main{id duration(format:"seconds")source:channel{id __typename}url{canonical __typename}__typename}__typename}byline dateline dateModified datePublished dateRevised flyTitle:subheadline id image{...ImageInlineFragment ...ImageMainFragment ...ImagePromoFragment __typename}print{title:headline flyTitle:subheadline rubric:description section{id title:headline __typename}__typename}publication{id tegID title:headline flyTitle:subheadline datePublished regionsAllowed url{canonical __typename}__typename}rubric:description source:channel{id __typename}tegID text(format:"json")title:headline type url{canonical __typename}topic contentIdentity{forceAppWebview mediaType articleType __typename}__typename}fragment ImageInlineFragment on Media{inline{url{canonical __typename}width height __typename}__typename}fragment ImageMainFragment on Media{main{url{canonical __typename}width height __typename}__typename}fragment ImagePromoFragment on Media{promo{url{canonical __typename}id width height __typename}__typename}fragment ImageCoverFragment on Media{cover{headline width height url{canonical __typename}regionsAllowed __typename}__typename}', # noqa: E501 'operationName': 'SpecificWeeklyEditionQuery', 'variables': '{{"path":"{}"}}'.format(content_id), } diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index ad37e0414b..6d2fcb33f4 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -252,7 +252,7 @@ class Economist(BasicNewsRecipe): # downloaded with connection reset by peer (104) errors. delay = 3 - from_archive = True + from_archive = False recipe_specific_options = { 'date': { @@ -289,7 +289,13 @@ class Economist(BasicNewsRecipe): else: kwargs['user_agent'] = 'TheEconomist-Lamarr-android' br = BasicNewsRecipe.get_browser(self, *args, **kwargs) - br.addheaders += [('x-request-id', str(uuid4()))] + br.addheaders += [ + ('accept', '*/*'), + ('content-type', 'application/json'), + ('apollographql-client-name', 'mobile-app-apollo'), + ('apollographql-client-version', '3.50.0'), + ('x-request-id', str(uuid4())), + ] return br def publication_date(self): @@ -320,10 +326,7 @@ class Economist(BasicNewsRecipe): def get_content_id(self, ed_date): id_query = { - 'query': 'query EditionsQuery($from:Int$size:Int$ref:String!){section:canonical(ref:$ref){...EditionFragment __typename}}' - 'fragment EditionFragment on Content{hasPart(from:$from size:$size sort:"datePublished:desc")' - '{total parts{id datePublished image{...ImageCoverFragment __typename}__typename}__typename}__typename}' - 'fragment ImageCoverFragment on Media{cover{headline width height url{canonical __typename}regionsAllowed __typename}__typename}', + 'query': 'query EditionsQuery($from:Int$size:Int$ref:String!){section:canonical(ref:$ref){...EditionFragment __typename}}fragment EditionFragment on Content{hasPart(from:$from size:$size sort:"datePublished:desc"){total parts{id datePublished image{...ImageCoverFragment __typename}__typename}__typename}__typename}fragment ImageCoverFragment on Media{cover{headline width height url{canonical __typename}regionsAllowed __typename}__typename}', # noqa: E501 'operationName': 'EditionsQuery', 'variables':'{"from":0,"size":24,"ref":"/content/d06tg8j85rifiq3oo544c6b9j61dno2n"}', } @@ -350,7 +353,7 @@ class Economist(BasicNewsRecipe): content_id = self.get_content_id(edition_date) if content_id: query = { - 'query': 'query SpecificWeeklyEditionQuery($path:String!){section:canonical(ref:$path){...WeeklyEditionFragment __typename}}fragment WeeklyEditionFragment on Content{id type datePublished image{...ImageCoverFragment __typename}url{canonical __typename}hasPart(size:100 sort:"publication.context.position"){parts{...ArticleFragment __typename}__typename}__typename}fragment ArticleFragment on Content{articleSection{internal{id title:headline __typename}__typename}audio{main{id duration(format:"seconds")source:channel{id __typename}url{canonical __typename}__typename}__typename}byline dateline dateModified datePublished flyTitle:subheadline id image{...ImageInlineFragment ...ImageMainFragment ...ImagePromoFragment __typename}print{title:headline flyTitle:subheadline rubric:description section{id title:headline __typename}__typename}publication{id tegID title:headline flyTitle:subheadline datePublished regionsAllowed url{canonical __typename}__typename}rubric:description source:channel{id __typename}tegID text(format:"json")title:headline type url{canonical __typename}__typename}fragment ImageInlineFragment on Media{inline{url{canonical __typename}width height __typename}__typename}fragment ImageMainFragment on Media{main{url{canonical __typename}width height __typename}__typename}fragment ImagePromoFragment on Media{promo{url{canonical __typename}id width height __typename}__typename}fragment ImageCoverFragment on Media{cover{headline width height url{canonical __typename}regionsAllowed __typename}__typename}', # noqa: E501 + 'query': 'query SpecificWeeklyEditionQuery($path:String!){section:canonical(ref:$path){...WeeklyEditionFragment __typename}}fragment WeeklyEditionFragment on Content{id type datePublished image{...ImageCoverFragment __typename}url{canonical __typename}hasPart(size:100 sort:"publication.context.position"){parts{...ArticleFragment __typename}__typename}__typename}fragment ArticleFragment on Content{ad{grapeshot{channels{name __typename}__typename}__typename}articleSection{internal{id title:headline __typename}__typename}audio{main{id duration(format:"seconds")source:channel{id __typename}url{canonical __typename}__typename}__typename}byline dateline dateModified datePublished dateRevised flyTitle:subheadline id image{...ImageInlineFragment ...ImageMainFragment ...ImagePromoFragment __typename}print{title:headline flyTitle:subheadline rubric:description section{id title:headline __typename}__typename}publication{id tegID title:headline flyTitle:subheadline datePublished regionsAllowed url{canonical __typename}__typename}rubric:description source:channel{id __typename}tegID text(format:"json")title:headline type url{canonical __typename}topic contentIdentity{forceAppWebview mediaType articleType __typename}__typename}fragment ImageInlineFragment on Media{inline{url{canonical __typename}width height __typename}__typename}fragment ImageMainFragment on Media{main{url{canonical __typename}width height __typename}__typename}fragment ImagePromoFragment on Media{promo{url{canonical __typename}id width height __typename}__typename}fragment ImageCoverFragment on Media{cover{headline width height url{canonical __typename}regionsAllowed __typename}__typename}', # noqa: E501 'operationName': 'SpecificWeeklyEditionQuery', 'variables': '{{"path":"{}"}}'.format(content_id), } From 656f0e967ea1cfcd0aa8c8ca06ddcc9d1d5a105e Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Thu, 3 Apr 2025 22:07:06 +0530 Subject: [PATCH 2/5] ... --- recipes/economist.recipe | 4 +++- recipes/economist_free.recipe | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 6d2fcb33f4..003afb5dfb 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -277,6 +277,8 @@ class Economist(BasicNewsRecipe): if d and isinstance(d, str): if d.lower().strip() == 'yes': self.from_archive = False + elif d.lower().strip() == 'no': + self.from_archive = True needs_subscription = False @@ -376,7 +378,7 @@ class Economist(BasicNewsRecipe): # data = json.loads(raw)['data']['section'] # else: # data = json.loads(raw)['data']['canonical']['hasPart']['parts'][0] - data = json.loads(raw)['data']['canonical']['hasPart']['parts'][0] + data = json.loads(raw)['data']['section'] 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 6d2fcb33f4..003afb5dfb 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -277,6 +277,8 @@ class Economist(BasicNewsRecipe): if d and isinstance(d, str): if d.lower().strip() == 'yes': self.from_archive = False + elif d.lower().strip() == 'no': + self.from_archive = True needs_subscription = False @@ -376,7 +378,7 @@ class Economist(BasicNewsRecipe): # data = json.loads(raw)['data']['section'] # else: # data = json.loads(raw)['data']['canonical']['hasPart']['parts'][0] - data = json.loads(raw)['data']['canonical']['hasPart']['parts'][0] + data = json.loads(raw)['data']['section'] dt = datetime.fromisoformat(data['datePublished'][:-1]) + timedelta(seconds=time.timezone) dt = dt.strftime('%b %d, %Y') self.timefmt = ' [' + dt + ']' From 532b302f6028eae605c71f9ad17ae9b23d547c8a Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Thu, 3 Apr 2025 22:09:16 +0530 Subject: [PATCH 3/5] ... --- recipes/economist.recipe | 4 ++-- recipes/economist_free.recipe | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 003afb5dfb..459ab33c48 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -265,7 +265,7 @@ class Economist(BasicNewsRecipe): 'default': '600', }, 'de': { - 'short': 'Digital Edition', + 'short': 'Web Edition', 'long': 'Yes/No. Digital Edition does not skip some articles based on your location.', 'default': 'No', } @@ -277,7 +277,7 @@ class Economist(BasicNewsRecipe): if d and isinstance(d, str): if d.lower().strip() == 'yes': self.from_archive = False - elif d.lower().strip() == 'no': + elif d.lower().strip() == 'yes': self.from_archive = True needs_subscription = False diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 003afb5dfb..459ab33c48 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -265,7 +265,7 @@ class Economist(BasicNewsRecipe): 'default': '600', }, 'de': { - 'short': 'Digital Edition', + 'short': 'Web Edition', 'long': 'Yes/No. Digital Edition does not skip some articles based on your location.', 'default': 'No', } @@ -277,7 +277,7 @@ class Economist(BasicNewsRecipe): if d and isinstance(d, str): if d.lower().strip() == 'yes': self.from_archive = False - elif d.lower().strip() == 'no': + elif d.lower().strip() == 'yes': self.from_archive = True needs_subscription = False From a0e86f271b6473edbfce0b913441e05468ab4844 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Thu, 3 Apr 2025 22:11:24 +0530 Subject: [PATCH 4/5] ... --- recipes/economist.recipe | 2 -- recipes/economist_free.recipe | 2 -- 2 files changed, 4 deletions(-) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 459ab33c48..542dc170cb 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -276,8 +276,6 @@ class Economist(BasicNewsRecipe): d = self.recipe_specific_options.get('de') if d and isinstance(d, str): if d.lower().strip() == 'yes': - self.from_archive = False - elif d.lower().strip() == 'yes': self.from_archive = True needs_subscription = False diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 459ab33c48..542dc170cb 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -276,8 +276,6 @@ class Economist(BasicNewsRecipe): d = self.recipe_specific_options.get('de') if d and isinstance(d, str): if d.lower().strip() == 'yes': - self.from_archive = False - elif d.lower().strip() == 'yes': self.from_archive = True needs_subscription = False From 940df3ed4b528949e455009be3c58bc205df7a16 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Thu, 3 Apr 2025 22:38:18 +0530 Subject: [PATCH 5/5] Update reuters.recipe --- recipes/reuters.recipe | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/reuters.recipe b/recipes/reuters.recipe index b6ff42e80e..39c343eae5 100644 --- a/recipes/reuters.recipe +++ b/recipes/reuters.recipe @@ -54,9 +54,9 @@ class Reuters(BasicNewsRecipe): }, 'spr': { 'short': 'Include Sports sections?', - 'long':'Yes/No', - 'default': 'No' - } + 'long': 'Yes/No', + 'default': 'No', + }, } def __init__(self, *args, **kwargs): @@ -157,7 +157,7 @@ class Reuters(BasicNewsRecipe): body += ( '
' - + str(data['read_minutes']) + + str(data.get('read_minutes', '_')) + ' minute read | ' + str(data['word_count']) + ' words | '