You've already forked XiguaLiveDanmakuHelper
更新粉丝团
This commit is contained in:
@ -11,6 +11,7 @@ class Gift:
|
||||
self.count = 0
|
||||
self.amount = 0
|
||||
self.user = None
|
||||
self.backupName = None
|
||||
if json:
|
||||
self.parse(json)
|
||||
|
||||
@ -32,30 +33,34 @@ class Gift:
|
||||
else:
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
@staticmethod
|
||||
def update():
|
||||
p = requests.get("https://i.snssdk.com/videolive/gift/get_gift_list?room_id={roomID}"
|
||||
"&version_code=800&device_platform=android".format(roomID=self.roomID))
|
||||
"&version_code=800&device_platform=android".format(roomID=Gift.roomID))
|
||||
d = p.json()
|
||||
if "gift_info" not in d:
|
||||
print("错误:礼物更新失败")
|
||||
else:
|
||||
for i in d["gift_info"]:
|
||||
_id = int(i["id"])
|
||||
Gift.giftList[_id] = {"Name": i["name"], "Price": i["diamond_count"]}
|
||||
Gift.giftList[_id] = {"Name": i["name"], "Price": i["diamond_count"], "Type": i["type"]}
|
||||
|
||||
def isAnimate(self):
|
||||
return self.ID != 0 and self.ID in self.giftList and self.giftList[self.ID]["Type"] == 2
|
||||
|
||||
def _getGiftName(self):
|
||||
if self.ID in self.giftList:
|
||||
return self.giftList[self.ID]["Name"]
|
||||
elif self.backupName is not None:
|
||||
return self.backupName
|
||||
else:
|
||||
return "未知礼物[{}]".format(self.ID)
|
||||
|
||||
def __str__(self):
|
||||
if self.ID in self.giftList:
|
||||
giftN = self.giftList[self.ID]["Name"]
|
||||
else:
|
||||
giftN = "未知礼物[{}]".format(self.ID)
|
||||
return "{user} 送出的 {count} 个 {name}".format(user=self.user, count=self.count, name=giftN)
|
||||
return "{user} 送出的 {count} 个 {name}".format(user=self.user, count=self.count, name=self._getGiftName())
|
||||
|
||||
def __unicode__(self):
|
||||
return self.__str__()
|
||||
|
||||
def __repr__(self):
|
||||
if self.ID in self.giftList:
|
||||
giftN = self.giftList[self.ID]["Name"]
|
||||
else:
|
||||
giftN = "未知礼物"
|
||||
return "西瓜礼物【{}(ID:{})】".format(giftN, self.ID)
|
||||
return "西瓜礼物【{}(ID:{})】".format(self._getGiftName(), self.ID)
|
||||
|
Reference in New Issue
Block a user