From e040ab2d755a788f695a91398e6b048f100750c1 Mon Sep 17 00:00:00 2001 From: amtoaer Date: Thu, 30 Nov 2023 17:50:36 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=B0=9D=E8=AF=95=E9=99=8D=E4=BD=8E?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=87=AD=E6=8D=AE=E9=A2=91=E7=8E=87=EF=BC=8C?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E9=A3=8E=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- processor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/processor.py b/processor.py index 2130f65..bcbc2c5 100644 --- a/processor.py +++ b/processor.py @@ -19,6 +19,8 @@ client = httpx.AsyncClient(headers=HEADERS) +anchor = datetime.datetime.today() + async def cleanup() -> None: await client.aclose() @@ -93,12 +95,10 @@ async def manage_model(medias: list[dict], fav_list: FavoriteList) -> None: async def process() -> None: global anchor - if not await credential.check_valid(): - logger.error("Credential is invalid, skipped.") - return - if await credential.check_refresh(): + if datetime.datetime.now() > anchor and await credential.check_refresh(): try: await credential.refresh() + anchor = datetime.datetime.today() + datetime.timedelta(days=1) logger.info("Credential refreshed.") except Exception: logger.exception("Failed to refresh credential.")