mirror of
https://github.com/xfgryujk/blivedm.git
synced 2024-12-26 12:50:13 +08:00
开放平台客户端添加主播Open ID、修复一个web端解析弹幕消息时的报错
This commit is contained in:
parent
8f6d770e18
commit
60ce01927a
@ -60,6 +60,8 @@ class OpenLiveClient(ws_base.WebSocketClientBase):
|
||||
# 在调用init_room后初始化的字段
|
||||
self._room_owner_uid: Optional[int] = None
|
||||
"""主播用户ID"""
|
||||
self._room_owner_open_id: Optional[str] = None
|
||||
"""主播Open ID"""
|
||||
self._host_server_url_list: Optional[List[str]] = []
|
||||
"""弹幕服务器URL列表"""
|
||||
self._auth_body: Optional[str] = None
|
||||
@ -78,6 +80,13 @@ class OpenLiveClient(ws_base.WebSocketClientBase):
|
||||
"""
|
||||
return self._room_owner_uid
|
||||
|
||||
@property
|
||||
def room_owner_open_id(self) -> Optional[str]:
|
||||
"""
|
||||
主播Open ID,调用init_room后初始化
|
||||
"""
|
||||
return self._room_owner_open_id
|
||||
|
||||
@property
|
||||
def room_owner_auth_code(self):
|
||||
"""
|
||||
@ -181,6 +190,7 @@ class OpenLiveClient(ws_base.WebSocketClientBase):
|
||||
anchor_info = data['anchor_info']
|
||||
self._room_id = anchor_info['room_id']
|
||||
self._room_owner_uid = anchor_info['uid']
|
||||
self._room_owner_open_id = anchor_info['open_id']
|
||||
return True
|
||||
|
||||
async def _end_game(self):
|
||||
|
@ -55,7 +55,7 @@ class DanmakuMessage:
|
||||
return cls(
|
||||
uname=data['uname'],
|
||||
uid=data['uid'],
|
||||
open_id=data.get('open_id', ''), # 还没全量上线,先用get保险
|
||||
open_id=data['open_id'],
|
||||
uface=data['uface'],
|
||||
timestamp=data['timestamp'],
|
||||
room_id=data['room_id'],
|
||||
@ -89,7 +89,7 @@ class AnchorInfo:
|
||||
def from_dict(cls, data: dict):
|
||||
return cls(
|
||||
uid=data['uid'],
|
||||
open_id=data.get('open_id', ''), # 还没全量上线,先用get保险
|
||||
open_id=data['open_id'],
|
||||
uname=data['uname'],
|
||||
uface=data['uface'],
|
||||
)
|
||||
@ -178,7 +178,7 @@ class GiftMessage:
|
||||
return cls(
|
||||
room_id=data['room_id'],
|
||||
uid=data['uid'],
|
||||
open_id=data.get('open_id', ''), # 还没全量上线,先用get保险
|
||||
open_id=data['open_id'],
|
||||
uname=data['uname'],
|
||||
uface=data['uface'],
|
||||
gift_id=data['gift_id'],
|
||||
@ -218,7 +218,7 @@ class UserInfo:
|
||||
def from_dict(cls, data: dict):
|
||||
return cls(
|
||||
uid=data['uid'],
|
||||
open_id=data.get('open_id', ''), # 还没全量上线,先用get保险
|
||||
open_id=data['open_id'],
|
||||
uname=data['uname'],
|
||||
uface=data['uface'],
|
||||
)
|
||||
@ -314,7 +314,7 @@ class SuperChatMessage:
|
||||
return cls(
|
||||
room_id=data['room_id'],
|
||||
uid=data['uid'],
|
||||
open_id=data.get('open_id', ''), # 还没全量上线,先用get保险
|
||||
open_id=data['open_id'],
|
||||
uname=data['uname'],
|
||||
uface=data['uface'],
|
||||
message_id=data['message_id'],
|
||||
@ -392,7 +392,7 @@ class LikeMessage:
|
||||
return cls(
|
||||
uname=data['uname'],
|
||||
uid=data['uid'],
|
||||
open_id=data.get('open_id', ''), # 还没全量上线,先用get保险
|
||||
open_id=data['open_id'],
|
||||
uface=data['uface'],
|
||||
timestamp=data['timestamp'],
|
||||
room_id=data['room_id'],
|
||||
|
@ -125,6 +125,13 @@ class DanmakuMessage:
|
||||
mcolor = 0
|
||||
special_medal = 0
|
||||
|
||||
if len(info[5]) != 0:
|
||||
old_title = info[5][0]
|
||||
title = info[5][1]
|
||||
else:
|
||||
old_title = ''
|
||||
title = ''
|
||||
|
||||
return cls(
|
||||
mode=info[0][1],
|
||||
font_size=info[0][2],
|
||||
@ -161,8 +168,8 @@ class DanmakuMessage:
|
||||
ulevel_color=info[4][2],
|
||||
ulevel_rank=info[4][3],
|
||||
|
||||
old_title=info[5][0],
|
||||
title=info[5][1],
|
||||
old_title=old_title,
|
||||
title=title,
|
||||
|
||||
privilege_type=info[7],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user