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

Conversation

lc4t
Copy link
Contributor

@lc4t lc4t commented May 11, 2023

动机

批量下载时,大会员因为多端登录、大量下载行为而冻结,需要等待30min或主动刷新,此时,下载到的视频是无大会员情况下的清晰度。

也就是 #133A2问题。

解决方案

提供一个--vip-check 参数,给定时,会在下载前校验大会员状态,如果异常则直接退出。

ps: 在run()函数中直接return,不知道是否会引起其他异常?

poetry run yutto 'https://www.bilibili.com/bangumi/play/ep473904' -c 'x' -d 'download'  --with-metadata --vip-check
> WARN  以非大会员身份登录,注意无法下载会员专享剧集喔~
> 番剧  明日酱的水手服
> ERROR  启用了严格校验大会员模式,请检查SESSDATA或大会员状态!
echo $?
> 0

类型

  • ✨ feat: 添加新功能
  • 🐛 fix: 修复 bug
  • 📝 docs: 对文档进行修改
  • ♻️ refactor: 代码重构(既不是新增功能,也不是修改 bug 的代码变动)
  • ⚡ perf: 提高性能的代码修改
  • 🧑‍💻 dx: 优化开发体验
  • 🔨 workflow: 工作流变动
  • 🏷️ types: 类型声明修改
  • 🚧 wip: 工作正在进行中
  • ✅ test: 测试用例添加及修改
  • 🔨 build: 影响构建系统或外部依赖关系的更改
  • 👷 ci: 更改 CI 配置文件和脚本
  • ❓ chore: 其它不涉及源码以及测试的修改
  • ⬆️ deps: 依赖项修改
  • 🔖 release: 发布新版本

README.md Outdated
@@ -409,6 +409,11 @@ cat ~/.yutto_alias | yutto tensura-nikki --batch --alias-file -
- 参数 `--metadata-only`
- 默认值 `False`

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

- 参数 `--vip-check`
Copy link
Member

Choose a reason for hiding this comment

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

是否可以修改下参数名称,比如加上 forcestrict 这样的修饰,因为 vip_check 现在是有的,只是不会退出

Copy link
Contributor Author

Choose a reason for hiding this comment

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

一开始我是打算叫vip_strict的,那就用一开始的吧,我改一下

@@ -256,6 +263,9 @@ async def run(args_list: list[argparse.Namespace]):
f"{episode_data['filename']}",
Badge(f"[{i+1}/{len(download_list)}]", fore="black", back="cyan"),
)
if args.vip_check and not await validate_vip():
Logger.error("启用了严格校验大会员模式,请检查SESSDATA或大会员状态!")
return
Copy link
Member

Choose a reason for hiding this comment

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

批量下载时,大会员因为多端登录、大量下载行为而冻结,需要等待30min或主动刷新

这种情况是可能发生在这个循环中的是嘛?如果是的话我觉得没问题

Copy link
Contributor Author

Choose a reason for hiding this comment

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

嗯是的,循环中间大会员失效了。

Copy link
Contributor Author

@lc4t lc4t May 11, 2023

Choose a reason for hiding this comment

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

不过需要关注一个不太优雅的问题:

 [876/1256]  ...
 ERROR  启用了严格校验大会员模式,请检查SESSDATA或大会员状态!
/Users/lc4t/miniforge3/lib/python3.9/asyncio/events.py:80: RuntimeWarning: coroutine 'extract_ugc_video_data' was never awaited
  self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

# 然后就退出了

Copy link
Member

Choose a reason for hiding this comment

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

这应该是一个已知问题,可以提交一个 issue,我会在之后修复一下~

用户的 KeyboardInterrupt 也会触发该问题

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~

@@ -254,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前,如果失效就会少请求几次

@SigureMo SigureMo merged commit 673a423 into yutto-dev:main May 11, 2023
@lc4t lc4t deleted the vip_check branch May 11, 2023 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants