Skip to content

Commit

Permalink
feat: 命令默认不覆盖现有内容,更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoaer committed Dec 5, 2023
1 parent 1686c1a commit 9d151b4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 参数,将全量覆盖对应内容,否则默认仅更新缺失的部分。**

## 路线图

Expand Down
11 changes: 7 additions & 4 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 5 additions & 1 deletion entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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:
Expand Down

0 comments on commit 9d151b4

Please sign in to comment.