Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: 添加大会员失效时退出 #134

Merged
merged 4 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ cat ~/.yutto_alias | yutto tensura-nikki --batch --alias-file -
- 参数 `--metadata-only`
- 默认值 `False`

#### 严格校验大会员状态有效

- 参数 `--vip-strict`
- 默认值 `False`

#### 不显示颜色

- 参数 `--no-color`
Expand Down
13 changes: 12 additions & 1 deletion yutto/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
initial_validation,
validate_basic_arguments,
validate_batch_argments,
validate_vip,
)

DownloadResourceType: TypeAlias = Literal["video", "audio", "subtitle", "metadata", "danmaku"]
Expand Down Expand Up @@ -157,12 +158,18 @@ def cli() -> argparse.ArgumentParser:
action=create_select_required_action(select=["metadata"], deselect=invert_selection(["metadata"])),
help="仅生成元数据文件",
)

group_common.set_defaults(
require_video=True, require_audio=True, require_subtitle=True, require_metadata=False, require_danmaku=True
require_video=True,
require_audio=True,
require_subtitle=True,
require_metadata=False,
require_danmaku=True,
)
group_common.add_argument("--no-color", action="store_true", help="不使用颜色")
group_common.add_argument("--no-progress", action="store_true", help="不显示进度条")
group_common.add_argument("--debug", action="store_true", help="启用 debug 模式")
group_common.add_argument("--vip-strict", action="store_true", help="启用严格检查大会员生效")

# 仅批量下载使用
group_batch = parser.add_argument_group("batch", "批量下载参数")
Expand Down Expand Up @@ -247,6 +254,9 @@ async def run(args_list: list[argparse.Namespace]):
for i, episode_data_coro in enumerate(download_list):
if episode_data_coro is None:
continue
if args.vip_strict and not await validate_vip():
Logger.error("启用了严格校验大会员模式,请检查SESSDATA或大会员状态!")
return
Copy link
Member

@SigureMo SigureMo May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

推测是episode_data_coro没有执行完毕但return导致RuntimeWarning

是 episode_data_coro 创建了,但没有 await,download_list 后续循环里还有很多这样子的 item,调整这里的顺序是没有用的,这个我会在之后有时间的时候提一个 PR 统一修复

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,不过就保持这个顺序吧,检查大会员在await episode_data_coro前,如果失效就会少请求几次

# 这时候才真正开始解析链接
episode_data = await episode_data_coro
if episode_data is None:
Expand All @@ -256,6 +266,7 @@ async def run(args_list: list[argparse.Namespace]):
f"{episode_data['filename']}",
Badge(f"[{i+1}/{len(download_list)}]", fore="black", back="cyan"),
)

await start_downloader(
session,
episode_data,
Expand Down