Skip to content

Commit

Permalink
✨ feat: add --vip-strict option (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
lc4t authored May 11, 2023
1 parent 7f1116d commit 673a423
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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
# 这时候才真正开始解析链接
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

0 comments on commit 673a423

Please sign in to comment.