Skip to content

Commit

Permalink
chore: 尝试降低更新凭据频率,防止风控
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoaer committed Nov 30, 2023
1 parent ad977e4 commit e040ab2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

client = httpx.AsyncClient(headers=HEADERS)

anchor = datetime.datetime.today()


async def cleanup() -> None:
await client.aclose()
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit e040ab2

Please sign in to comment.