bilibili-api icon indicating copy to clipboard operation
bilibili-api copied to clipboard

[提问] 字幕无法获取的问题

Open nickyi1990 opened this issue 1 year ago • 2 comments

Python 版本: 3.8

运行环境: Linux


我每天大概获取100次字幕,大概12后发现所有视频都无法获取字幕,第一次删除cookie后再用新的发现可以看到字幕了,后面这招也不管用了(PS:非登录状态下可以看到字幕),请问怎么解决这个问题

nickyi1990 avatar Feb 27 '24 14:02 nickyi1990

得周末调试看看,或者你自己比对下参数、cookie 有啥区别

z0z0r4 avatar Feb 28 '24 09:02 z0z0r4

基本上,不提供 cookie 会报错,我不知道你如何解决的

>>> sync(v.get_subtitle(1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python\Python312\Lib\site-packages\bilibili_api\utils\sync.py", line 33, in sync
    return loop.run_until_complete(coroutine)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\asyncio\base_events.py", line 684, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\site-packages\bilibili_api\video.py", line 1489, in get_subtitle
    return (await self.get_player_info(cid=cid)).get("subtitle")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\site-packages\bilibili_api\video.py", line 1520, in get_player_info
    await Api(**api, credential=self.credential).update_params(**params).result
  File "D:\Python\Python312\Lib\site-packages\bilibili_api\utils\network.py", line 273, in result
    self.__result = await self.request()
                    ^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\site-packages\bilibili_api\utils\network.py", line 173, in inner
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\site-packages\bilibili_api\utils\network.py", line 537, in request
    config = await self._prepare_request(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\site-packages\bilibili_api\utils\network.py", line 425, in _prepare_request
    self.credential.raise_for_no_sessdata()
  File "D:\Python\Python312\Lib\site-packages\bilibili_api\utils\credential.py", line 126, in raise_for_no_sessdata
    raise CredentialNoSessdataException()
bilibili_api.exceptions.CredentialNoSessdataException.CredentialNoSessdataException: Credential 类未提供 sessdata 或者为空。

请检查你的版本是否为最新

z0z0r4 avatar Mar 15 '24 14:03 z0z0r4