File ~/anaconda3/lib/python3.12/site-packages/nest_asyncio.py:98, in _patch_loop..run_until_complete(self, future)
95 if not f.done():
96 raise RuntimeError(
97 'Event loop stopped before Future completed.')
---> 98 return f.result()
File ~/anaconda3/lib/python3.12/asyncio/futures.py:203, in Future.result(self)
201 self.__log_traceback = False
202 if self._exception is not None:
--> 203 raise self._exception.with_traceback(self._exception_tb)
204 return self._result
File ~/anaconda3/lib/python3.12/asyncio/tasks.py:314, in Task.step_run_and_handle_result(failed resolving arguments)
310 try:
311 if exc is None:
312 # We use the send method directly, because coroutines
313 # don't have `iterandnext__` methods.
--> 314 result = coro.send(None)
315 else:
316 result = coro.throw(exc)
File ~/anaconda3/lib/python3.12/site-packages/bilibili_api/video.py:883, in Video.get_danmakus(self, page_index, date, cid, from_seg, to_seg)
881 if to_seg == None:
882 view = await self.get_danmaku_view(cid=cid)
--> 883 to_seg = view["dm_seg"]["total"] - 1
885 danmakus = []
887 for seg in range(from_seg, to_seg + 1):
Python 版本: 3.12
模块版本: x.y.z
运行环境: Linux
这个还在维护嘛
这是我的代码
获取rank排行 实时查询查询在线观看人数 收集弹幕
import asyncio from bilibili_api import video
实例化
v = video.Video(bvid="BV15EtgeUEaD")
获取在线人数
print(sync(v.get_online()))
print(sync(v.get_danmakus())) #此处会报错
KeyError Traceback (most recent call last) Cell In[43], line 10 7 # 获取在线人数 8 print(sync(v.get_online())) ---> 10 print(sync(v.get_danmakus()))
File ~/anaconda3/lib/python3.12/site-packages/bilibili_api/utils/sync.py:33, in sync(coroutine) 31 __ensure_event_loop() 32 loop = asyncio.get_event_loop() ---> 33 return loop.run_until_complete(coroutine)
File ~/anaconda3/lib/python3.12/site-packages/nest_asyncio.py:98, in _patch_loop..run_until_complete(self, future)
95 if not f.done():
96 raise RuntimeError(
97 'Event loop stopped before Future completed.')
---> 98 return f.result()
File ~/anaconda3/lib/python3.12/asyncio/futures.py:203, in Future.result(self) 201 self.__log_traceback = False 202 if self._exception is not None: --> 203 raise self._exception.with_traceback(self._exception_tb) 204 return self._result
File ~/anaconda3/lib/python3.12/asyncio/tasks.py:314, in Task.step_run_and_handle_result(failed resolving arguments) 310 try: 311 if exc is None: 312 # We use the
send
method directly, because coroutines 313 # don't have `iterand
next__` methods. --> 314 result = coro.send(None) 315 else: 316 result = coro.throw(exc)File ~/anaconda3/lib/python3.12/site-packages/bilibili_api/video.py:883, in Video.get_danmakus(self, page_index, date, cid, from_seg, to_seg) 881 if to_seg == None: 882 view = await self.get_danmaku_view(cid=cid) --> 883 to_seg = view["dm_seg"]["total"] - 1 885 danmakus = [] 887 for seg in range(from_seg, to_seg + 1):
KeyError: 'total' Selection deleted