Skip to content

Commit

Permalink
fix: 加入靠谱的凭据更新机制
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoaer committed Nov 26, 2023
1 parent e977f12 commit eee99d9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from nfo import Actor, EpisodeInfo
from settings import settings

anchor = datetime.datetime.today()

client = httpx.AsyncClient(headers=HEADERS)


Expand Down Expand Up @@ -95,11 +93,12 @@ async def manage_model(medias: list[dict], fav_list: FavoriteList) -> None:

async def process() -> None:
global anchor
if (datetime.datetime.now() - anchor).days >= 3:
# 暂定三天刷新一次凭据,具体看情况调整
if not await credential.check_valid():
logger.error("Credential is invalid, skipped.")
return
if await credential.check_refresh():
try:
credential.refresh()
anchor = datetime.datetime.today()
logger.info("Credential refreshed.")
except Exception:
logger.exception("Failed to refresh credential.")
Expand Down

0 comments on commit eee99d9

Please sign in to comment.