You've already forked XiguaLiveDanmakuHelper
							
							修复:因isValidRoom判断错误导致的无法获取弹幕,修正抽奖结束时间判断
This commit is contained in:
		
							
								
								
									
										12
									
								
								Lottery.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Lottery.py
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
import requests
 | 
			
		||||
 | 
			
		||||
import time
 | 
			
		||||
from LuckyUser import LuckyUser
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -11,6 +11,7 @@ class Lottery:
 | 
			
		||||
    luckyUsers = []
 | 
			
		||||
    joinedUserCount = 0
 | 
			
		||||
    prizeName = ""
 | 
			
		||||
    finish:int = 0
 | 
			
		||||
 | 
			
		||||
    def __init__(self, json=None):
 | 
			
		||||
        if json:
 | 
			
		||||
@@ -26,6 +27,15 @@ class Lottery:
 | 
			
		||||
                self.content = i["content"]
 | 
			
		||||
            self.joinedUserCount = int(json["lottery_info"]["candidate_num"])
 | 
			
		||||
            self.prizeName = json["lottery_info"]["prize_info"]["name"]
 | 
			
		||||
            _delta = int(json["lottery_info"]["draw_time"]) - int(json["lottery_info"]["current_time"])
 | 
			
		||||
            self.finish = time.time()+_delta+1
 | 
			
		||||
 | 
			
		||||
    def update(self):
 | 
			
		||||
        if self.finish > time.time():
 | 
			
		||||
            self.checkFinished()
 | 
			
		||||
            return True
 | 
			
		||||
        else:
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
    def checkFinished(self):
 | 
			
		||||
        p = requests.get("https://i.snssdk.com/videolive/lottery/check_user_right?lottery_id={}"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								api.py
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								api.py
									
									
									
									
									
								
							@@ -104,7 +104,8 @@ class XiGuaLiveApi:
 | 
			
		||||
            p = s.get("https://security.snssdk.com/video/app/search/live/?version_code=730&device_platform=android"
 | 
			
		||||
                      "&format=json&keyword={}".format(self.name))
 | 
			
		||||
            d = p.json()
 | 
			
		||||
            if "data" in d:
 | 
			
		||||
            self.isValidRoom = d["base_resp"]["status_code"] == 0
 | 
			
		||||
            if "data" in d and d["data"] is not None:
 | 
			
		||||
                for i in d["data"]:
 | 
			
		||||
                    if i["block_type"] != 0:
 | 
			
		||||
                        continue
 | 
			
		||||
@@ -145,6 +146,7 @@ class XiGuaLiveApi:
 | 
			
		||||
 | 
			
		||||
    def getDanmaku(self):
 | 
			
		||||
        if not self.isValidRoom:
 | 
			
		||||
            self.updRoomInfo()
 | 
			
		||||
            return
 | 
			
		||||
        p = s.get("https://i.snssdk.com/videolive/im/get_msg?cursor={cursor}&room_id={roomID}"
 | 
			
		||||
                  "&version_code=730&device_platform=android".format(
 | 
			
		||||
@@ -188,12 +190,12 @@ class XiGuaLiveApi:
 | 
			
		||||
            else:
 | 
			
		||||
                pass
 | 
			
		||||
        self._updRoomCount += 1
 | 
			
		||||
        if self.lottery is not None:
 | 
			
		||||
            self.lottery.update()
 | 
			
		||||
        if self._updRoomCount > 120 or len(d['data']) == 0:
 | 
			
		||||
            if self.lottery is not None:
 | 
			
		||||
                self.lottery.checkFinished()
 | 
			
		||||
                if self.lottery.isFinished:
 | 
			
		||||
                    self.onLottery(self.lottery)
 | 
			
		||||
                    self.lottery = None
 | 
			
		||||
            if self.lottery.isFinished:
 | 
			
		||||
                self.onLottery(self.lottery)
 | 
			
		||||
                self.lottery = None
 | 
			
		||||
            self.updRoomInfo()
 | 
			
		||||
            self._updRoomCount = 0
 | 
			
		||||
            return
 | 
			
		||||
 
 | 
			
		||||
@@ -422,8 +422,6 @@ class Bilibili:
 | 
			
		||||
                                  "videos": self.videos}
 | 
			
		||||
                              )
 | 
			
		||||
        print(r.text)
 | 
			
		||||
        for _p in self.files:
 | 
			
		||||
            os.remove(_p.path)
 | 
			
		||||
 | 
			
		||||
    def addChannel(self, name, intro=''):
 | 
			
		||||
        """
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user