From 9d151b47310f6249e031007d60c60c48e60f98b9 Mon Sep 17 00:00:00 2001 From: amtoaer Date: Wed, 6 Dec 2023 01:19:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=91=BD=E4=BB=A4=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E4=B8=8D=E8=A6=86=E7=9B=96=E7=8E=B0=E6=9C=89=E5=86=85=E5=AE=B9?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 +++++++++++++++++--- commands.py | 11 +++++++---- entry.py | 6 +++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ed3d6d5..c9ace6d 100644 --- a/README.md +++ b/README.md @@ -88,15 +88,29 @@ services: 为满足需要,该应用包含几个单独的命令,可在程序目录下使用 `python entry.py ${command name}` 运行。 -1. `once` +1. `once` 处理收藏夹,和一般定时任务触发时执行的操作完全相同,但仅运行一次。 2. `recheck` 将本地不存在的视频文件标记成未下载,下次定时任务触发时将一并下载。 -3. `upper_thumb` +3. `refresh_refresh_poster` - 手动触发全量下载 up 主头像,为使用老版本时下载的没有 up 头像的视频添加头像。 + 更新本地视频的封面。 +3. `refresh_upper` + + 更新本地up的头像和元数据。 +3. `refresh_nfo` + + 更新本地视频的元数据。(如标签、标题等信息) +3. `refresh_video` + + 更新本地的视频源文件。 +3. `refresh_subtitle` + + 更新本地的弹幕文件。 + +**对于以 refresh 开头的命令,均支持 --force 参数,如果有 --force 参数,将全量覆盖对应内容,否则默认仅更新缺失的部分。** ## 路线图 diff --git a/commands.py b/commands.py index 4a14fa8..8080ec0 100644 --- a/commands.py +++ b/commands.py @@ -47,12 +47,15 @@ async def _refresh_favorite_item_info( process_nfo: bool = False, process_upper: bool = False, process_subtitle: bool = False, + force: bool = False, ): items = await FavoriteItem.filter(downloaded=True).prefetch_related("upper") - await asyncio.gather( - *[aremove(path) for item in items for path in path_getter(item)], - return_exceptions=True, - ) + if force: + # 如果强制刷新,那么就先把现存的所有内容删除 + await asyncio.gather( + *[aremove(path) for item in items for path in path_getter(item)], + return_exceptions=True, + ) await asyncio.gather( *[ process_favorite_item( diff --git a/entry.py b/entry.py index 5260f50..48f9c7b 100644 --- a/entry.py +++ b/entry.py @@ -21,6 +21,7 @@ async def entry() -> None: await init_model() + force = any("force" in _ for _ in sys.argv) for command, func in ( ("once", process), ("recheck", recheck), @@ -32,7 +33,10 @@ async def entry() -> None: ): if any(command in _ for _ in sys.argv): logger.info("Running {}...", command) - await func() + if command.startswith("refresh"): + await func(force=force) + else: + await func() return logger.info("Running daemon...") while True: