You've already forked XiguaLiveDanmakuHelper
改进部分代码,增加Linux可运行的版本,可自己选择想要进入的房间
Signed-off-by: Jerry Yan <792602257@qq.com>
This commit is contained in:
44
User.py
Normal file
44
User.py
Normal file
@ -0,0 +1,44 @@
|
||||
class User:
|
||||
ID: int = 0
|
||||
name: str = ""
|
||||
brand: str = ""
|
||||
level: int = 0
|
||||
type: int = 0
|
||||
|
||||
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']
|
||||
self.type = json["Msg"]['user']['user_type']
|
||||
if "discipulus_info" in json["Msg"]:
|
||||
self.level = json["Msg"]["discipulus_info"]["level"]
|
||||
self.brand = json["Msg"]["discipulus_info"]["discipulus_group_title"]
|
||||
elif "data" in json:
|
||||
if "anchorInfo" in json["data"]:
|
||||
self.ID = json["data"]['anchorInfo']['user_id']
|
||||
self.name = json["data"]['anchorInfo']['name']
|
||||
self.type = 0
|
||||
if self.type is None:
|
||||
self.type = 0
|
||||
|
||||
def __str__(self):
|
||||
if self.level == 0:
|
||||
if self.type == 1:
|
||||
return "[房管]{}".format(self.name)
|
||||
elif self.type == 2:
|
||||
return "[主播]{}".format(self.name)
|
||||
else:
|
||||
return "{}".format(self.name)
|
||||
else:
|
||||
if self.type != 0:
|
||||
return "[{}{}]{}".format(self.brand, self.level, self.name)
|
||||
return "<{}{}>{}".format(self.brand,self.level,self.name)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.__str__()
|
||||
|
Reference in New Issue
Block a user