From 2d05b83add5d4bb9fede3caf1f9770072a0ff6b7 Mon Sep 17 00:00:00 2001 From: Braxen Date: Sun, 4 Dec 2022 23:18:23 +0100 Subject: [PATCH] feat(server): python binary config var --- Dockerfile | 1 + common/ServerConfig.ts | 1 + server/src/Core/Config.ts | 3 ++- server/src/Core/Helper.ts | 10 ++++++++++ server/src/Helpers/Software.ts | 4 ++-- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd9d2fc5..d8ada305 100644 --- a/Dockerfile +++ b/Dockerfile @@ -112,6 +112,7 @@ COPY ./docker/fonts /home/node/.fonts # twitchautomator docker specific configs ENV TCD_BIN_DIR=/usr/local/bin ENV TCD_FFMPEG_PATH=/usr/bin/ffmpeg +ENV TCD_BIN_PATH_PYTHON=/usr/bin/python ENV TCD_MEDIAINFO_PATH=/usr/bin/mediainfo ENV TCD_NODE_PATH=/usr/local/bin/node ENV TCD_DOCKER=1 diff --git a/common/ServerConfig.ts b/common/ServerConfig.ts index 6c6de21e..caeb6616 100644 --- a/common/ServerConfig.ts +++ b/common/ServerConfig.ts @@ -8,6 +8,7 @@ export const settingsFields: Record | SettingField< mediainfo_path: { group: "Binaries", text: "Mediainfo path", type: "string", "required": true }, twitchdownloader_path: { group: "Binaries", text: "TwitchDownloaderCLI path", type: "string" }, node_path: { group: "Binaries", text: "NodeJS path", type: "string" }, + "bin_path.python": { group: "Binaries", text: "Python path", type: "string", "required": false }, server_port: { group: "Basic", text: "Server port", type: "number", default: 8080 }, basepath: { group: "Basic", text: "Base path", type: "string", help: "No trailing slash. For reverse proxy etc", "stripslash": true }, diff --git a/server/src/Core/Config.ts b/server/src/Core/Config.ts index d6c93a35..0bc071d1 100644 --- a/server/src/Core/Config.ts +++ b/server/src/Core/Config.ts @@ -117,7 +117,7 @@ export class Config { console.warn(chalk.red(`Setting '${key}' does not exist.`)); } - if (process.env[`TCD_${key.toUpperCase()}`] !== undefined) { + if (process.env[`TCD_${key.toUpperCase().replaceAll(".", "_")}`] !== undefined) { return true; } @@ -330,6 +330,7 @@ export class Config { Scheduler.restartScheduler(); await YouTubeHelper.setupClient(); await TwitchHelper.setupWebsocket(); + LiveStreamDVR.binaryVersions = {}; // reset binary versions for the next page visit } backupConfig() { diff --git a/server/src/Core/Helper.ts b/server/src/Core/Helper.ts index 61f4be77..ac4e4a81 100644 --- a/server/src/Core/Helper.ts +++ b/server/src/Core/Helper.ts @@ -48,6 +48,16 @@ export class Helper { return false; } + public static path_python(): string | false { + if (Config.getInstance().hasValue("bin_path.python")) return Config.getInstance().cfg("bin_path.python"); + return false; + } + + // public static path_python3(): string | false { + // if (Config.getInstance().hasValue("bin_path.python3")) return Config.getInstance().cfg("bin_path.python3"); + // return false; + // } + // very bad public static path_ffprobe(): string | false { const f = this.path_ffmpeg(); diff --git a/server/src/Helpers/Software.ts b/server/src/Helpers/Software.ts index 8c8b74fb..186a2139 100644 --- a/server/src/Helpers/Software.ts +++ b/server/src/Helpers/Software.ts @@ -18,8 +18,8 @@ export function DVRBinaries(): Record { ffmpeg: { binary: Helper.path_ffmpeg(), version_args: ["-version"], version_regex: /ffmpeg version ([\w0-9\-_.+]+) Copyright/m }, mediainfo: { binary: Helper.path_mediainfo(), version_args: ["--Version"], version_regex: /v(\d+\.\d+)/m }, twitchdownloader: { binary: Helper.path_twitchdownloader(), version_args: ["--version", "2>&1"], version_regex: /TwitchDownloaderCLI (\d+\.\d+\.\d+)/m }, - python: { binary: "python", version_args: ["--version"], version_regex: /Python ([\d.]+)/m }, - python3: { binary: "python3", version_args: ["--version"], version_regex: /Python ([\d.]+)/m }, + python: { binary: Helper.path_python(), version_args: ["--version"], version_regex: /Python ([\d.]+)/m }, + // python3: { binary: Helper.path_python3(), version_args: ["--version"], version_regex: /Python ([\d.]+)/m }, node: { binary: Helper.path_node(), version_args: ["--version"], version_regex: /v([\d.]+)/m }, // php: { binary: "php", version_args: ["-v"], version_regex: /PHP Version ([\d.]+)/m }, // deprecated };