Merge remote-tracking branch 'origin/with_api' into with_api

This commit is contained in:
Jerry Yan 2019-04-22 05:59:47 +08:00
commit 03ce8df291
3 changed files with 33 additions and 2 deletions

View File

@ -98,6 +98,8 @@ forceNotDownload = False
forceNotBroadcasting = False
forceNotUpload = False
forceNotEncode = False
forceStartEncodeThread = False
forceStartUploadThread = False
uploadQueue = queue.Queue()
encodeQueue = queue.Queue()

View File

@ -72,6 +72,22 @@ def toggleForceNotBroadcast():
}})
@app.route("/force/start/encode", methods=["POST"])
def toggleForceStartEncodeThread():
Common.forceStartEncodeThread = True
Common.appendOperation("强制运行编码线程")
return jsonify({"message":"ok","code":200,"status":0,"data":{
}})
@app.route("/force/start/upload", methods=["POST"])
def toggleForceStartUploadThread():
Common.forceStartUploadThread = True
Common.appendOperation("强制运行上传线程")
return jsonify({"message":"ok","code":200,"status":0,"data":{
}})
@app.route("/encode/insert", methods=["POST"])
def insertEncode():
if "filename" in request.form and os.path.exists(request.form["filename"]):

View File

@ -60,8 +60,8 @@ def encode():
continue
if os.path.exists(i):
isEncode = True
if os.path.getsize(path) < 8 * 1024 * 1024:
Common.appendEncodeStatus("Encoded File >{}< is too small, will ignore it".format(path))
if os.path.getsize(i) < 8 * 1024 * 1024:
Common.appendEncodeStatus("Encoded File >{}< is too small, will ignore it".format(i))
continue
Common.appendEncodeStatus("Encoding >{}< Start".format(i))
os.system("ffmpeg -i {} -c:v copy -c:a copy -f mp4 {} -y".format(i, i[:13] + ".mp4"))
@ -173,3 +173,16 @@ def run():
_count_error = 0
except Exception as e:
Common.appendError(e.__str__())
if Common.forceStartEncodeThread:
if not et.is_alive():
et = threading.Thread(target=encode, args=())
et.setDaemon(True)
et.start()
Common.forceStartEncodeThread = False
if Common.forceStartUploadThread:
if not ut.is_alive():
d = datetime.strftime(datetime.now(), "%Y_%m_%d")
ut = threading.Thread(target=upload, args=(d,))
ut.setDaemon(True)
ut.start()
Common.forceStartUploadThread = False