diff --git a/Common.py b/Common.py index 26a0d7c..7894a22 100644 --- a/Common.py +++ b/Common.py @@ -98,6 +98,8 @@ forceNotDownload = False forceNotBroadcasting = False forceNotUpload = False forceNotEncode = False +forceStartEncodeThread = False +forceStartUploadThread = False uploadQueue = queue.Queue() encodeQueue = queue.Queue() diff --git a/WebMain.py b/WebMain.py index 3f6ae5e..bd856b7 100644 --- a/WebMain.py +++ b/WebMain.py @@ -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"]): diff --git a/liveDownloader.py b/liveDownloader.py index ba5409e..d53fedd 100644 --- a/liveDownloader.py +++ b/liveDownloader.py @@ -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