From 60ce01927a3d17ecc069d8f5f8ed62ffc0075e31 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 17 Mar 2024 18:39:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E6=94=BE=E5=B9=B3=E5=8F=B0=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E6=B7=BB=E5=8A=A0=E4=B8=BB=E6=92=ADOpen=20ID?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AAweb=E7=AB=AF?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E5=BC=B9=E5=B9=95=E6=B6=88=E6=81=AF=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blivedm/clients/open_live.py | 10 ++++++++++ blivedm/models/open_live.py | 12 ++++++------ blivedm/models/web.py | 11 +++++++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/blivedm/clients/open_live.py b/blivedm/clients/open_live.py index 0b00a2f..b94a299 100644 --- a/blivedm/clients/open_live.py +++ b/blivedm/clients/open_live.py @@ -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): diff --git a/blivedm/models/open_live.py b/blivedm/models/open_live.py index 2282a0c..7954989 100644 --- a/blivedm/models/open_live.py +++ b/blivedm/models/open_live.py @@ -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'], diff --git a/blivedm/models/web.py b/blivedm/models/web.py index 2025695..1473f49 100644 --- a/blivedm/models/web.py +++ b/blivedm/models/web.py @@ -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], )