Skip to content

Commit

Permalink
feat(server): python binary config var
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBrax committed Dec 4, 2022
1 parent 05e0c14 commit 2d05b83
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions common/ServerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const settingsFields: Record<string, SettingField<string> | 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 },
Expand Down
3 changes: 2 additions & 1 deletion server/src/Core/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 10 additions & 0 deletions server/src/Core/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("bin_path.python");
return false;
}

// public static path_python3(): string | false {
// if (Config.getInstance().hasValue("bin_path.python3")) return Config.getInstance().cfg<string>("bin_path.python3");
// return false;
// }

// very bad
public static path_ffprobe(): string | false {
const f = this.path_ffmpeg();
Expand Down
4 changes: 2 additions & 2 deletions server/src/Helpers/Software.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export function DVRBinaries(): Record<string, BinaryDef> {
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
};
Expand Down

0 comments on commit 2d05b83

Please sign in to comment.