Nemo2011 / bilibili-api

哔哩哔哩常用API调用。支持视频、番剧、用户、频道、音频等功能。原仓库地址:https://github.com/MoyuScript/bilibili-api
https://nemo2011.github.io/bilibili-api/
GNU General Public License v3.0
2.19k stars 210 forks source link

【提问】无法下载历史弹幕 #248

Closed debuggerzh closed 1 year ago

debuggerzh commented 1 year ago

Python 版本: 3.10

模块版本: 15.3.1

运行环境: Windows


如题,下载历史弹幕的代码报错提示Credential 类未提供 sessdata

import datetime

from bilibili_api import ass, sync, video
from bilibili_api import Credential

cred = Credential(sessdata="我的sessdata",
                  ……)

dt = datetime.date(2022, 5, 5)

sync(ass.make_ass_file_danmakus_protobuf(video.Video("BV1AV411x7Gs"), 0,
                                         dt.strftime("%Y-%m-%d"), credential=cred,
                                         date=dt))

image

Drelf2018 commented 1 year ago

make_ass_file_danmakus_protobuf() 的第一个参数(Video)加上凭证:

- video.Video("BV1AV411x7Gs")
+ video.Video("BV1AV411x7Gs", credential=cred)
Drelf2018 commented 1 year ago

https://github.com/Nemo2011/bilibili-api/blob/main/bilibili_api/ass.py#L141-L143

@Nemo2011 这函数既然已经要求了传入 credential 并且判断过了,是不是在后续处理的时候给没有 credentialobj 添加上这个 credential

不过感觉也不太好,是否传入 credential 也应该由使用者自行决定。