添加prod判断
This commit is contained in:
parent
289a46ab42
commit
07e695c945
@ -1,5 +1,9 @@
|
||||
import configparser
|
||||
import os.path
|
||||
from flask.helpers import get_env
|
||||
|
||||
|
||||
PROD_ENV = get_env() == "production"
|
||||
|
||||
# [danmaku]
|
||||
# exec
|
||||
|
@ -1,6 +1,6 @@
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
from config import get_config, write_config, load_config
|
||||
from config import get_config, write_config, load_config, PROD_ENV
|
||||
|
||||
blueprint = Blueprint("api_config", __name__, url_prefix="/api/config")
|
||||
|
||||
@ -10,6 +10,13 @@ def get_global_config():
|
||||
return jsonify(get_config())
|
||||
|
||||
|
||||
@blueprint.get("/env")
|
||||
def get_current_env():
|
||||
return jsonify({
|
||||
"prod": PROD_ENV
|
||||
})
|
||||
|
||||
|
||||
@blueprint.put("/")
|
||||
def modify_global_config():
|
||||
return jsonify(request.json)
|
||||
|
@ -4,7 +4,7 @@ import subprocess
|
||||
from datetime import datetime, timedelta
|
||||
from typing import IO
|
||||
|
||||
from config import FFMPEG_EXEC, VIDEO_BITRATE, FFMPEG_USE_GPU, VIDEO_CLIP_EACH_SEC, VIDEO_CLIP_OVERFLOW_SEC
|
||||
from config import FFMPEG_EXEC, VIDEO_BITRATE, FFMPEG_USE_GPU, VIDEO_CLIP_EACH_SEC, VIDEO_CLIP_OVERFLOW_SEC, PROD_ENV
|
||||
|
||||
|
||||
def get_video_real_duration(filename):
|
||||
@ -33,6 +33,7 @@ def encode_video_with_subtitles(orig_filename: str, subtitles: list[str], new_fi
|
||||
new_filename
|
||||
], stdout=subprocess.PIPE)
|
||||
handle_ffmpeg_output(encode_process.stdout)
|
||||
return encode_process.wait()
|
||||
|
||||
|
||||
def handle_ffmpeg_output(stderr: IO[bytes]) -> None:
|
||||
@ -40,6 +41,9 @@ def handle_ffmpeg_output(stderr: IO[bytes]) -> None:
|
||||
line = stderr.readline()
|
||||
if line == b"":
|
||||
break
|
||||
if PROD_ENV:
|
||||
# 正式环境不要输出一大堆的东西了
|
||||
continue
|
||||
if line.startswith(b"out_time="):
|
||||
cur_time = line.replace(b"out_time=", b"").decode()
|
||||
print("CurTime", cur_time.strip())
|
||||
|
Loading…
x
Reference in New Issue
Block a user