From 10616d6c88be2ff54bc04cc744bf3bbfe6c90a46 Mon Sep 17 00:00:00 2001 From: jeancf Date: Wed, 23 Nov 2022 14:55:43 +0100 Subject: [PATCH] Simplified is_time_valid() --- twoot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/twoot.py b/twoot.py index 70ddd70..e89b8f7 100755 --- a/twoot.py +++ b/twoot.py @@ -317,12 +317,12 @@ def contains_class(body_classes, some_class): return found -def is_time_valid(timestamp, max_age, min_delay): +def is_time_valid(timestamp): ret = True # Check that the tweet is not too young (might be deleted) or too old age_in_hours = (time.time() - float(timestamp)) / 3600.0 - min_delay_in_hours = min_delay / 60.0 - max_age_in_hours = max_age * 24.0 + min_delay_in_hours = TOML['options']['tweet_delay'] / 60.0 + max_age_in_hours = TOML['options']['tweet_max_age'] * 24.0 if age_in_hours < min_delay_in_hours or age_in_hours > max_age_in_hours: ret = False @@ -596,7 +596,7 @@ def main(argv): timestamp = datetime.datetime.strptime(time_string, '%b %d, %Y ยท %I:%M %p %Z').timestamp() # Check if time is within acceptable range - if not is_time_valid(timestamp, TOML['options']['tweet_max_age'], TOML['options']['tweet_delay']): + if not is_time_valid(timestamp): out_date_cnt += 1 logging.debug("Tweet outside valid time range, skipping") continue