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

✨是否可以增加作为包调用的 api? #100

Open
2 tasks done
astro-jingtao opened this issue Dec 22, 2022 · 3 comments
Open
2 tasks done

✨是否可以增加作为包调用的 api? #100

astro-jingtao opened this issue Dec 22, 2022 · 3 comments

Comments

@astro-jingtao
Copy link

特性描述

增加作为包调用的 api?比如

from yutto import yutto_api

output = yutto_api(url, c='******************', danmaku='xml') # 等价于 yutto <url> -c '******************' --danmaku xml

print(output.log) # 用命令行下载时输出在屏幕上的内容
print(output.danmaku) # xml

建议解决方案

No response

额外信息

No response

一点点的自我检查

  • 充分阅读 README.md,特别是与本 issue 相关的部分
  • 本 issue 在 issuesdiscussion 中并没有重复问题
@SigureMo
Copy link
Member

唔,暂时没有相关计划,可以暂时使用 subprocess 来实现部分相似的效果……(可参考 e2e test https://github.com/yutto-dev/yutto/blob/main/tests/test_e2e.py

@astro-jingtao
Copy link
Author

唔,暂时没有相关计划,可以暂时使用 subprocess 来实现部分相似的效果……(可参考 e2e test https://github.com/yutto-dev/yutto/blob/main/tests/test_e2e.py

感谢回复,我尝试了 subprocess 但可能是因为我用 conda 管理环境,每次都要用 subprocess 都要重新激活,有点低效。而且不知道我是哪里搞错了 subprocess 即便提供登录信息也没法下载 1080p (之前我用 youget,就是因为它现在下载不了高分辨率的视频所以找到了这个包)。

我现在的做法是参考 yutto/__main__.pyargs = parser.parse_args() 那步传参数,然后重定向输出到变量,我的需求也比较简单,暂时没有发现什么问题。

以上供有同样需求的朋友参考。

@dd178
Copy link

dd178 commented Apr 2, 2023

import sys
from yutto import __main__ as yutto

sys.argv = ['yutto', url, '-c', SESSDATA, '-d', path]
yutto.main()

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

No branches or pull requests

3 participants