部分逻辑,更改名字
This commit is contained in:
parent
86fbf31120
commit
a6662450de
@ -23,7 +23,7 @@ streamUrl = ""
|
|||||||
isBroadcasting = False
|
isBroadcasting = False
|
||||||
updateTime = ""
|
updateTime = ""
|
||||||
|
|
||||||
forceStopDownload = False
|
forceNotDownload = False
|
||||||
forceNotBroadcasting = False
|
forceNotBroadcasting = False
|
||||||
forceNotUpload = True
|
forceNotUpload = True
|
||||||
forceNotEncode = True
|
forceNotEncode = True
|
||||||
@ -143,7 +143,7 @@ class downloader(XiGuaLiveApi):
|
|||||||
playlist = None
|
playlist = None
|
||||||
|
|
||||||
def updRoomInfo(self):
|
def updRoomInfo(self):
|
||||||
global broadcaster, isBroadcasting, updateTime, forceNotBroadcasting, forceStopDownload
|
global broadcaster, isBroadcasting, updateTime, forceNotBroadcasting, forceNotDownload
|
||||||
super(downloader, self).updRoomInfo()
|
super(downloader, self).updRoomInfo()
|
||||||
updateTime = datetime.strftime(datetime.now(), dt_format)
|
updateTime = datetime.strftime(datetime.now(), dt_format)
|
||||||
broadcaster = self.roomLiver
|
broadcaster = self.roomLiver
|
||||||
@ -151,7 +151,7 @@ class downloader(XiGuaLiveApi):
|
|||||||
if self.isLive:
|
if self.isLive:
|
||||||
self.updPlayList()
|
self.updPlayList()
|
||||||
else:
|
else:
|
||||||
forceStopDownload = False
|
forceNotDownload = False
|
||||||
forceNotBroadcasting = False
|
forceNotBroadcasting = False
|
||||||
self.playlist = False
|
self.playlist = False
|
||||||
self.files = []
|
self.files = []
|
||||||
|
36
WebMain.py
36
WebMain.py
@ -36,6 +36,38 @@ def writeConfig():
|
|||||||
return jsonify({"message":"ok","code":200,"status":0,"data":request.form})
|
return jsonify({"message":"ok","code":200,"status":0,"data":request.form})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/force/not/upload", methods=["POST"])
|
||||||
|
def toggleForceNotUpload():
|
||||||
|
Common.forceNotUpload = not Common.forceNotUpload
|
||||||
|
return jsonify({"message":"ok","code":200,"status":0,"data":{
|
||||||
|
"forceNotUpload": Common.forceNotUpload,
|
||||||
|
}})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/force/not/encode", methods=["POST"])
|
||||||
|
def toggleForceNotEncode():
|
||||||
|
Common.forceNotEncode = not Common.forceNotEncode
|
||||||
|
return jsonify({"message":"ok","code":200,"status":0,"data":{
|
||||||
|
"forceNotEncode": Common.forceNotEncode,
|
||||||
|
}})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/force/not/download", methods=["POST"])
|
||||||
|
def toggleForceNotDownload():
|
||||||
|
Common.forceNotDownload = not Common.forceNotDownload
|
||||||
|
return jsonify({"message":"ok","code":200,"status":0,"data":{
|
||||||
|
"forceNotDownload": Common.forceNotDownload,
|
||||||
|
}})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/force/not/broadcast", methods=["POST"])
|
||||||
|
def toggleForceNotBroadcast():
|
||||||
|
Common.forceNotBroadcasting = not Common.forceNotBroadcasting
|
||||||
|
return jsonify({"message":"ok","code":200,"status":0,"data":{
|
||||||
|
"forceNotBroadcasting": Common.forceNotBroadcasting,
|
||||||
|
}})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/encode/insert", methods=["POST"])
|
@app.route("/encode/insert", methods=["POST"])
|
||||||
def insertEncode():
|
def insertEncode():
|
||||||
if "filename" in request.form:
|
if "filename" in request.form:
|
||||||
@ -74,7 +106,7 @@ def getAllStats():
|
|||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"forceNotBroadcasting": Common.forceNotBroadcasting,
|
"forceNotBroadcasting": Common.forceNotBroadcasting,
|
||||||
"forceStopDownload": Common.forceStopDownload,
|
"forceNotDownload": Common.forceNotDownload,
|
||||||
"forceNotUpload": Common.forceNotUpload,
|
"forceNotUpload": Common.forceNotUpload,
|
||||||
"forceNotEncode": Common.forceNotEncode,
|
"forceNotEncode": Common.forceNotEncode,
|
||||||
},
|
},
|
||||||
@ -115,7 +147,7 @@ def getConfigStats():
|
|||||||
return jsonify({"message":"ok","code":200,"status":0,"data":{
|
return jsonify({"message":"ok","code":200,"status":0,"data":{
|
||||||
"config": {
|
"config": {
|
||||||
"forceNotBroadcasting": Common.forceNotBroadcasting,
|
"forceNotBroadcasting": Common.forceNotBroadcasting,
|
||||||
"forceStopDownload": Common.forceStopDownload,
|
"forceNotDownload": Common.forceNotDownload,
|
||||||
"forceNotUpload": Common.forceNotUpload,
|
"forceNotUpload": Common.forceNotUpload,
|
||||||
}
|
}
|
||||||
}})
|
}})
|
||||||
|
@ -13,7 +13,7 @@ isDownload = False
|
|||||||
|
|
||||||
|
|
||||||
def download(url):
|
def download(url):
|
||||||
global isDownload, forceStopDownload
|
global isDownload, forceNotDownload
|
||||||
path = datetime.strftime(datetime.now(), "%Y%m%d_%H%M.flv")
|
path = datetime.strftime(datetime.now(), "%Y%m%d_%H%M.flv")
|
||||||
p = requests.get(url, stream=True)
|
p = requests.get(url, stream=True)
|
||||||
if p.status_code != 200:
|
if p.status_code != 200:
|
||||||
@ -28,7 +28,7 @@ def download(url):
|
|||||||
f.write(t)
|
f.write(t)
|
||||||
_size = os.path.getsize(path)
|
_size = os.path.getsize(path)
|
||||||
modifyLastDownloadStatus("Downloading >{}< @ {:.2f}%".format(path, 100.0 * _size/config["p_s"]))
|
modifyLastDownloadStatus("Downloading >{}< @ {:.2f}%".format(path, 100.0 * _size/config["p_s"]))
|
||||||
if _size > config["p_s"] or forceStopDownload:
|
if _size > config["p_s"] or forceNotDownload:
|
||||||
break
|
break
|
||||||
modifyLastDownloadStatus("Download >{}< Finished".format(path))
|
modifyLastDownloadStatus("Download >{}< Finished".format(path))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -36,14 +36,13 @@ def download(url):
|
|||||||
e.__str__()))
|
e.__str__()))
|
||||||
f.close()
|
f.close()
|
||||||
isDownload = False
|
isDownload = False
|
||||||
if os.path.getsize(path) == 0:
|
if os.path.getsize(path) < 1024 * 1024:
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
return False
|
return False
|
||||||
encodeQueue.put(path)
|
if forceNotDownload:
|
||||||
if forceStopDownload:
|
|
||||||
forceStopDownload = False
|
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
encodeQueue.put(path)
|
||||||
download(url)
|
download(url)
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +52,8 @@ def encode():
|
|||||||
while True:
|
while True:
|
||||||
i = encodeQueue.get()
|
i = encodeQueue.get()
|
||||||
if forceNotEncode:
|
if forceNotEncode:
|
||||||
modifyLastEncodeStatus("设置了不编码,所以[{}]不会编码".format(i))
|
appendEncodeStatus("设置了不编码,所以[{}]不会编码".format(i))
|
||||||
|
uploadQueue.put(i)
|
||||||
continue
|
continue
|
||||||
if os.path.exists(i):
|
if os.path.exists(i):
|
||||||
isEncode = True
|
isEncode = True
|
||||||
@ -73,7 +73,7 @@ def upload(date=datetime.strftime(datetime.now(), "%Y_%m_%d")):
|
|||||||
i = uploadQueue.get()
|
i = uploadQueue.get()
|
||||||
while True:
|
while True:
|
||||||
if forceNotUpload:
|
if forceNotUpload:
|
||||||
modifyLastUploadStatus("设置了不上传,所以[{}]不会上传了".format(i))
|
appendUploadStatus("设置了不上传,所以[{}]不会上传了".format(i))
|
||||||
i = uploadQueue.get()
|
i = uploadQueue.get()
|
||||||
continue
|
continue
|
||||||
if isinstance(i, bool):
|
if isinstance(i, bool):
|
||||||
@ -119,7 +119,7 @@ def run(name):
|
|||||||
if api.isLive and not forceNotBroadcasting:
|
if api.isLive and not forceNotBroadcasting:
|
||||||
if d is None:
|
if d is None:
|
||||||
d = datetime.strftime(datetime.now(), "%Y_%m_%d")
|
d = datetime.strftime(datetime.now(), "%Y_%m_%d")
|
||||||
if not t.is_alive() and not forceStopDownload:
|
if not t.is_alive() and not forceNotDownload:
|
||||||
_count_error += 1
|
_count_error += 1
|
||||||
_preT = api.playlist
|
_preT = api.playlist
|
||||||
t = threading.Thread(target=download, args=(_preT,))
|
t = threading.Thread(target=download, args=(_preT,))
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>是否设置强制不下载</td>
|
<td>是否设置强制不下载</td>
|
||||||
<td><span id="forceStopDownload"></span></td>
|
<td><span id="forceNotDownload"></span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>是否设置强制不上传</td>
|
<td>是否设置强制不上传</td>
|
||||||
|
@ -7,7 +7,7 @@ function taskUpdate(){
|
|||||||
$("#isBroadcasting").text(res.data.broadcast.isBroadcasting)
|
$("#isBroadcasting").text(res.data.broadcast.isBroadcasting)
|
||||||
$("#streamUrl").text(res.data.broadcast.streamUrl)
|
$("#streamUrl").text(res.data.broadcast.streamUrl)
|
||||||
$("#forceNotBroadcasting").text(res.data.config.forceNotBroadcasting)
|
$("#forceNotBroadcasting").text(res.data.config.forceNotBroadcasting)
|
||||||
$("#forceStopDownload").text(res.data.config.forceStopDownload)
|
$("#forceNotDownload").text(res.data.config.forceNotDownload)
|
||||||
$("#forceNotUpload").text(res.data.config.forceNotUpload)
|
$("#forceNotUpload").text(res.data.config.forceNotUpload)
|
||||||
$("#forceNotEncode").text(res.data.config.forceNotEncode)
|
$("#forceNotEncode").text(res.data.config.forceNotEncode)
|
||||||
$("#updateTime").text(res.data.broadcast.updateTime)
|
$("#updateTime").text(res.data.broadcast.updateTime)
|
||||||
|
Reference in New Issue
Block a user