You've already forked XiguaLiveDanmakuHelper
Api使用Android app弹幕协议
This commit is contained in:
22
User.py
22
User.py
@ -4,25 +4,33 @@ class User:
|
||||
brand: str = ""
|
||||
level: int = 0
|
||||
type: int = 0
|
||||
block: bool = False
|
||||
mute: bool = False
|
||||
|
||||
def __init__(self, json=None):
|
||||
if json:
|
||||
self.parse(json)
|
||||
|
||||
def parse(self, json):
|
||||
if "Msg" in json:
|
||||
if "user" in json["Msg"]:
|
||||
self.ID = json["Msg"]['user']['user_id']
|
||||
self.name = json["Msg"]['user']['name']
|
||||
if "discipulus_info" in json["Msg"]:
|
||||
self.level = json["Msg"]["discipulus_info"]["level"]
|
||||
self.brand = json["Msg"]["discipulus_info"]["discipulus_group_title"]
|
||||
if "extra" in json:
|
||||
if "user" in json["extra"] and json["extra"]["user"] is not None:
|
||||
self.ID = json["extra"]['user']['user_id']
|
||||
self.name = json["extra"]['user']['name']
|
||||
if "im_discipulus_info" in json["extra"] and json["extra"]["im_discipulus_info"] is not None:
|
||||
self.level = json["extra"]["im_discipulus_info"]["level"]
|
||||
self.brand = json["extra"]["im_discipulus_info"]["discipulus_group_title"]
|
||||
if "user_room_auth_status" in json["extra"] and json["extra"]["user_room_auth_status"] is not None:
|
||||
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 "data" in json:
|
||||
if "anchorInfo" in json["data"]:
|
||||
self.ID = json["data"]['anchorInfo']['id']
|
||||
self.name = json["data"]['anchorInfo']['name']
|
||||
if self.type is None:
|
||||
self.type = 0
|
||||
if isinstance(self.level, str):
|
||||
self.level = int(self.level)
|
||||
|
||||
def __str__(self):
|
||||
if self.level == 0:
|
||||
|
Reference in New Issue
Block a user