diff --git a/Struct/User.py b/Struct/User.py index 87c2c42..4db684c 100644 --- a/Struct/User.py +++ b/Struct/User.py @@ -23,13 +23,17 @@ class User: self.type = json["extra"]["user_room_auth_status"]["user_type"] self.block = json["extra"]["user_room_auth_status"]["is_block"] self.mute = json["extra"]["user_room_auth_status"]["is_silence"] - elif "user_info" in json and json["user_info"] is not None: + if "user_info" in json and json["user_info"] is not None: self.ID = json['user_info']['user_id'] self.name = json['user_info']['name'] - elif "anchor" in json and json["anchor"] is not None: + if "anchor" in json and json["anchor"] is not None: if "user_info" in json["anchor"] and json["anchor"]['user_info'] is not None: self.ID = json["anchor"]['user_info']['user_id'] self.name = json["anchor"]['user_info']['name'] + if "user_id" in json: + self.ID = json["user_id"] + if "user_name" in json: + self.name = json["user_name"] if self.type is None: self.type = 0 if isinstance(self.level, str): diff --git a/api.py b/api.py index 4df0684..c8e9639 100644 --- a/api.py +++ b/api.py @@ -162,16 +162,19 @@ class XiGuaLiveApi: for i in d["data"]: if self.broadcaster is not None: break - if i["block_type"] != 0: + if i["block_type"] != 2: continue if "cells" not in i or len(i["cells"]) == 0: break for _j in i["cells"]: - _user = User(_j) - if self._checkUsernameIsMatched(_user): - self.isValidUser = True - self.broadcaster = _user - break + if "room" in _j: + _user = User(_j["room"]) + self.roomID = _j["room"]["room_id"] + self.isLive = _j["room"]["is_living"] + if self._checkUsernameIsMatched(_user): + self.isValidUser = True + self.broadcaster = _user + break self._updRoomAt = datetime.now() return self._updateUserInfo()