From 86e4aa483f39fcf0cdb930bc297af0fc8a287c9d Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 18 Apr 2019 10:37:13 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=BC=BA=E5=88=B6=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common.py | 2 ++ WebMain.py | 16 ++++++++++++++++ liveDownloader.py | 13 +++++++++++++ 3 files changed, 31 insertions(+) diff --git a/Common.py b/Common.py index 9bb2a11..ad6328f 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..e95e7fd 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 toggleForceStartEncodeThread(): + 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 7d95f2c..f3aa933 100644 --- a/liveDownloader.py +++ b/liveDownloader.py @@ -174,3 +174,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.forceStartEncodeThread = False From 69b594cf8ee33ebb31a783423035b127f313f6c8 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 18 Apr 2019 10:39:25 +0800 Subject: [PATCH 2/5] ...Typo Error --- WebMain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebMain.py b/WebMain.py index e95e7fd..bd856b7 100644 --- a/WebMain.py +++ b/WebMain.py @@ -81,7 +81,7 @@ def toggleForceStartEncodeThread(): @app.route("/force/start/upload", methods=["POST"]) -def toggleForceStartEncodeThread(): +def toggleForceStartUploadThread(): Common.forceStartUploadThread = True Common.appendOperation("强制运行上传线程") return jsonify({"message":"ok","code":200,"status":0,"data":{ From b3162b1ed5677009aa9721547c2dd4a5c5b2733b Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 18 Apr 2019 10:43:04 +0800 Subject: [PATCH 3/5] ...Typo Error --- liveDownloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liveDownloader.py b/liveDownloader.py index f3aa933..b037a7e 100644 --- a/liveDownloader.py +++ b/liveDownloader.py @@ -61,7 +61,7 @@ def encode(): continue if os.path.exists(i): isEncode = True - if os.path.getsize(path) < 8 * 1024 * 1024: + if os.path.getsize(i) < 8 * 1024 * 1024: Common.appendEncodeStatus("Encoded File >{}< is too small, will ignore it".format(path)) continue Common.appendEncodeStatus("Encoding >{}< Start".format(i)) From e520e39b721490c99a541650fa2ae5c5930caa52 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 18 Apr 2019 10:43:27 +0800 Subject: [PATCH 4/5] ...Typo Error --- liveDownloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liveDownloader.py b/liveDownloader.py index b037a7e..68a44c4 100644 --- a/liveDownloader.py +++ b/liveDownloader.py @@ -62,7 +62,7 @@ def encode(): if os.path.exists(i): isEncode = True if os.path.getsize(i) < 8 * 1024 * 1024: - Common.appendEncodeStatus("Encoded File >{}< is too small, will ignore it".format(path)) + 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")) From d17d0bd5347c03e6990edc09531f642331513753 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 18 Apr 2019 10:47:29 +0800 Subject: [PATCH 5/5] ...Typo Error --- liveDownloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liveDownloader.py b/liveDownloader.py index 68a44c4..ca646b5 100644 --- a/liveDownloader.py +++ b/liveDownloader.py @@ -186,4 +186,4 @@ def run(): ut = threading.Thread(target=upload, args=(d,)) ut.setDaemon(True) ut.start() - Common.forceStartEncodeThread = False + Common.forceStartUploadThread = False