mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-05 07:28:04 +08:00
feat: 加入凭据刷新逻辑,每日至多检查一次更新
This commit is contained in:
+14
-1
@@ -8,6 +8,9 @@ from asyncio import create_subprocess_exec
|
|||||||
from asyncio.subprocess import DEVNULL
|
from asyncio.subprocess import DEVNULL
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
anchor = datetime.datetime.today()
|
||||||
|
|
||||||
|
|
||||||
async def download_content(url: str, path: Path):
|
async def download_content(url: str, path: Path):
|
||||||
@@ -21,8 +24,18 @@ async def download_content(url: str, path: Path):
|
|||||||
|
|
||||||
|
|
||||||
async def process():
|
async def process():
|
||||||
|
global anchor
|
||||||
|
if (
|
||||||
|
datetime.datetime.now() - anchor
|
||||||
|
).days >= 1 and await credential.check_refresh():
|
||||||
|
try:
|
||||||
|
credential.refresh()
|
||||||
|
anchor += datetime.timedelta(days=1)
|
||||||
|
logger.info("Credential refreshed.")
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Failed to refresh credential.")
|
||||||
|
return
|
||||||
favorite_ids, tasks = [], []
|
favorite_ids, tasks = [], []
|
||||||
|
|
||||||
for favorite_id in settings.favorite_ids:
|
for favorite_id in settings.favorite_ids:
|
||||||
if favorite_id not in settings.path_mapper:
|
if favorite_id not in settings.path_mapper:
|
||||||
logger.warning(f"Favorite {favorite_id} not in path mapper, ignored.")
|
logger.warning(f"Favorite {favorite_id} not in path mapper, ignored.")
|
||||||
|
|||||||
Reference in New Issue
Block a user