You've already forked XiguaLiveDanmakuHelper
修正因未开播而导致的Queue内占满了False的BUG
This commit is contained in:
@ -12,7 +12,7 @@ q = queue.Queue()
|
|||||||
base_uri = ""
|
base_uri = ""
|
||||||
isUpload = False
|
isUpload = False
|
||||||
uq = queue.Queue()
|
uq = queue.Queue()
|
||||||
d = datetime.strftime(datetime.now(),"%Y_%m_%d")
|
|
||||||
|
|
||||||
class downloader(XiGuaLiveApi):
|
class downloader(XiGuaLiveApi):
|
||||||
files = []
|
files = []
|
||||||
@ -32,24 +32,34 @@ class downloader(XiGuaLiveApi):
|
|||||||
|
|
||||||
def onLike(self, user):
|
def onLike(self, user):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onAd(self, i):
|
def onAd(self, i):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onChat(self, chat):
|
def onChat(self, chat):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onEnter(self, msg):
|
def onEnter(self, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onJoin(self, user):
|
def onJoin(self, user):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onLeave(self, json):
|
def onLeave(self, json):
|
||||||
self.updRoomInfo()
|
self.updRoomInfo()
|
||||||
|
|
||||||
def onMessage(self, msg):
|
def onMessage(self, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onPresent(self, gift):
|
def onPresent(self, gift):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onPresentEnd(self, gift):
|
def onPresentEnd(self, gift):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onSubscribe(self, user):
|
def onSubscribe(self, user):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def preDownload(self):
|
def preDownload(self):
|
||||||
global base_uri
|
global base_uri
|
||||||
if self.playlist:
|
if self.playlist:
|
||||||
@ -66,6 +76,7 @@ class downloader(XiGuaLiveApi):
|
|||||||
len(self.files)))
|
len(self.files)))
|
||||||
q.put(i)
|
q.put(i)
|
||||||
self.genNewName()
|
self.genNewName()
|
||||||
|
|
||||||
def genNewName(self):
|
def genNewName(self):
|
||||||
if len(self.files) > 800:
|
if len(self.files) > 800:
|
||||||
q.put(True)
|
q.put(True)
|
||||||
@ -93,10 +104,9 @@ def download(path=datetime.strftime(datetime.now(),"%Y%m%d_%H%M.ts")):
|
|||||||
n = True
|
n = True
|
||||||
i = q.get()
|
i = q.get()
|
||||||
if n:
|
if n:
|
||||||
|
isUpload = True
|
||||||
uq.put(path)
|
uq.put(path)
|
||||||
print("{} : Download Daemon Quiting".format(datetime.strftime(datetime.now(), "%y%m%d %H%M")))
|
print("{} : Download Daemon Quiting".format(datetime.strftime(datetime.now(), "%y%m%d %H%M")))
|
||||||
isUpload = True
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def upload(date=datetime.strftime(datetime.now(), "%Y_%m_%d")):
|
def upload(date=datetime.strftime(datetime.now(), "%Y_%m_%d")):
|
||||||
@ -104,11 +114,12 @@ def upload(date = datetime.strftime(datetime.now(), "%Y_%m_%d")):
|
|||||||
i = uq.get()
|
i = uq.get()
|
||||||
while True:
|
while True:
|
||||||
if isinstance(i, bool):
|
if isinstance(i, bool):
|
||||||
|
print("{} : Upload Daemon Receive Command {}"
|
||||||
|
.format(datetime.strftime(datetime.now(), "%y%m%d %H%M"), i))
|
||||||
if i is True:
|
if i is True:
|
||||||
print("自动投稿中,请稍后")
|
print("自动投稿中,请稍后")
|
||||||
b.finishUpload(config["t_t"].format(date), 17, config["tag"], config["des"],
|
b.finishUpload(config["t_t"].format(date), 17, config["tag"], config["des"],
|
||||||
source="https://live.ixigua.com/userlive/97621754276", no_reprint=0)
|
source="https://live.ixigua.com/userlive/97621754276", no_reprint=0)
|
||||||
print("{} : Upload Daemon Receive Command {}".format(datetime.strftime(datetime.now(), "%y%m%d %H%M"), i))
|
|
||||||
break
|
break
|
||||||
print("{} : Upload {}".format(datetime.strftime(datetime.now(), "%y%m%d %H%M"), i))
|
print("{} : Upload {}".format(datetime.strftime(datetime.now(), "%y%m%d %H%M"), i))
|
||||||
try:
|
try:
|
||||||
@ -140,6 +151,7 @@ if __name__ == "__main__":
|
|||||||
input("房间不存在")
|
input("房间不存在")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
print("=" * 30)
|
print("=" * 30)
|
||||||
|
d = datetime.strftime(datetime.now(), "%Y_%m_%d")
|
||||||
_preT = datetime.strftime(datetime.now(), "%Y%m%d_%H%M.ts")
|
_preT = datetime.strftime(datetime.now(), "%Y%m%d_%H%M.ts")
|
||||||
t = threading.Thread(target=download, args=(_preT,))
|
t = threading.Thread(target=download, args=(_preT,))
|
||||||
ut = threading.Thread(target=upload, args=(d,))
|
ut = threading.Thread(target=upload, args=(d,))
|
||||||
@ -162,7 +174,9 @@ if __name__ == "__main__":
|
|||||||
pass
|
pass
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
else:
|
else:
|
||||||
|
if d is not None:
|
||||||
q.put(False)
|
q.put(False)
|
||||||
|
d = None
|
||||||
if isUpload:
|
if isUpload:
|
||||||
uq.put(True)
|
uq.put(True)
|
||||||
isUpload = False
|
isUpload = False
|
||||||
@ -170,5 +184,4 @@ if __name__ == "__main__":
|
|||||||
pass
|
pass
|
||||||
# print("主播未开播,等待1分钟后重试")
|
# print("主播未开播,等待1分钟后重试")
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
d=None
|
|
||||||
api.updRoomInfo()
|
api.updRoomInfo()
|
||||||
|
Reference in New Issue
Block a user