From 791a305421b7c5f8a89c6754626fad17ece94148 Mon Sep 17 00:00:00 2001 From: datawhores Date: Mon, 18 Dec 2023 22:26:43 -0600 Subject: [PATCH] add special for 1 post missing to timeline --- ofscraper/api/timeline.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ofscraper/api/timeline.py b/ofscraper/api/timeline.py index 90af01674..af3f8529e 100644 --- a/ofscraper/api/timeline.py +++ b/ofscraper/api/timeline.py @@ -318,12 +318,15 @@ def get_after(model_id, username): if len(curr) == 0: log.debug("Setting date to zero because database is empty") return 0 - num_missing = len(list(filter(lambda x: x[-2] == 0, curr))) - if num_missing == 0: + missing_items = list(filter(lambda x: x[-2] == 0, curr)) + if len(missing_items) == 0: log.debug("Using last db date because,all downloads in db marked as downloaded") return operations.get_last_timeline_date(model_id=model_id, username=username) + elif len(missing_items) == 1: + log.debug("Setting date slightly before single missing item") + return arrow.get(missing_items[-1][-1]).float_timestamp - 1000 else: log.debug( - f"Setting date to zero because {num_missing} posts in db are marked as undownloaded" + f"Setting date to zero because {len(missing_items)} posts in db are marked as undownloaded" ) return 0