From 9b044bd9c6b4224403e3503f3ff3f59dd4c0742e Mon Sep 17 00:00:00 2001 From: anandd Date: Fri, 14 Feb 2025 12:04:11 -0500 Subject: [PATCH 1/2] fix oldest article logic --- recipes/the_wire.recipe | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/recipes/the_wire.recipe b/recipes/the_wire.recipe index 52d4a4c045..0126ec0b88 100644 --- a/recipes/the_wire.recipe +++ b/recipes/the_wire.recipe @@ -1,4 +1,5 @@ #!/usr/bin/env python +import datetime import json from calibre.web.feeds.news import BasicNewsRecipe @@ -73,6 +74,13 @@ class TheWire(BasicNewsRecipe): continue if not b.get('post_type', '') == 'post': continue + now = datetime.now(datetime.timezone.utc) # Ensure 'now' is offset-aware + self.log(now) + post_date = datetime.strptime(b['post_date'], '%Y-%m-%d %H:%M:%S').replace(tzinfo=datetime.timezone.utc) # Make 'post_date' offset-aware + self.log(post_date) + if (now - post_date).days > 1: + self.log('Skipping', title, 'as it is too old') + continue title = b['post_title'] desc = b['post_excerpt'] slg = b['categories'][0]['slug'] + '/' + b['post_name'] From 5357ad688602ad03bf6336806e3e15f8660f75b6 Mon Sep 17 00:00:00 2001 From: anandd Date: Fri, 14 Feb 2025 12:09:53 -0500 Subject: [PATCH 2/2] remove logging --- recipes/the_wire.recipe | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/the_wire.recipe b/recipes/the_wire.recipe index 0126ec0b88..7f85e0cec3 100644 --- a/recipes/the_wire.recipe +++ b/recipes/the_wire.recipe @@ -75,9 +75,7 @@ class TheWire(BasicNewsRecipe): if not b.get('post_type', '') == 'post': continue now = datetime.now(datetime.timezone.utc) # Ensure 'now' is offset-aware - self.log(now) post_date = datetime.strptime(b['post_date'], '%Y-%m-%d %H:%M:%S').replace(tzinfo=datetime.timezone.utc) # Make 'post_date' offset-aware - self.log(post_date) if (now - post_date).days > 1: self.log('Skipping', title, 'as it is too old') continue