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

[新功能] 能否将凭据类与凭据操作类的命名分开 #870

Open
psacal opened this issue Dec 11, 2024 · 4 comments
Open

[新功能] 能否将凭据类与凭据操作类的命名分开 #870

psacal opened this issue Dec 11, 2024 · 4 comments

Comments

@psacal
Copy link

psacal commented Dec 11, 2024

这两者的类名都叫做Credential,容易引起混乱和用法错误

@psacal psacal closed this as completed Dec 17, 2024
@Drelf2018
Copy link
Collaborator

Drelf2018 commented Dec 17, 2024

之前想回复你来着,最近忙小组作业搞忘了。

总的来说,只需要使用 from bilibili_api import Credential 即可,因为这个带有功能的类本来就继承了只含有属性的类,我觉得是没有必要去引用更初级的那个类的。

不知道你想做区分是什么原因?

@Drelf2018 Drelf2018 reopened this Dec 17, 2024
@psacal
Copy link
Author

psacal commented Dec 17, 2024

之前想回复你来着,最近忙小组作业搞忘了。

总的来说,只需要使用 from bilibili_api import Credential 即可,因为这个带有功能的类本来就继承了只含有属性的类,我觉得是没有必要去引用更初级的那个类的。

不知道你想做区分是什么原因?

说来就是我很蠢了,当时我在参考教程写一个视频下载器,因为实例化videoDownload需要用到credential类,所以我就按照教程实例化credential,结果在实例化时没有添加进ac_time_value参数,导致检测credential是否要刷新失败,提示没有这个方法,我以为是类名重合,其实是我没有按要求去做。后面干脆把实例化credential类的参数全部填上

@Drelf2018
Copy link
Collaborator

明白了,之所以分出两个类是为了解决循环引用的问题,因为发送请求的函数和凭据类不在一个文件,而发送请求需要用到凭据,所以凭据类必须被发送请求的那个文件引入。但是后面又新加了刷新凭据的接口,不得已才新增了现在这个凭据类。本质是它们两者没有很好解耦的问题,可能之后会修改。

@psacal
Copy link
Author

psacal commented Dec 17, 2024

谢谢解惑

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

2 participants