Skip to content

Commit

Permalink
check for ttvlol plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBrax committed Jan 22, 2024
1 parent 811f06e commit c318595
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions server/src/Core/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ export class Config {
Scheduler.restartScheduler();
await YouTubeHelper.setupClient();
await TwitchHelper.setupWebsocket();
await LiveStreamDVR.checkTTVLolPlugin();
LiveStreamDVR.binaryVersions = {}; // reset binary versions for the next page visit
i18next.changeLanguage(this.cfg("basic.language", "en"));
}
Expand Down
14 changes: 14 additions & 0 deletions server/src/Core/LiveStreamDVR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ export class LiveStreamDVR {

await LiveStreamDVR.checkBinaryVersions();

await LiveStreamDVR.checkTTVLolPlugin();

// monitor for program exit
// let saidGoobye = false;
// const goodbye = () => {
Expand Down Expand Up @@ -983,6 +985,10 @@ export class LiveStreamDVR {
}
}

if (Config.getInstance().cfg("capture.twitch-ttv-lol-plugin") && !this.ttvLolPluginAvailable) {
errors.push("Twitch TTV LOL plugin is enabled but not available.");
}

return errors;
}

Expand Down Expand Up @@ -1066,6 +1072,14 @@ export class LiveStreamDVR {
}
}

public static ttvLolPluginAvailable = false;
public static async checkTTVLolPlugin() {
if ( !Config.getInstance().cfg("capture.twitch-ttv-lol-plugin") ) return false; // not enabled
this.ttvLolPluginAvailable = await TwitchHelper.checkTTVLolPlugin();
return this.ttvLolPluginAvailable;
}


public static async checkPythonVirtualEnv() {
log(
LOGLEVEL.INFO,
Expand Down
3 changes: 2 additions & 1 deletion server/src/Core/Providers/Twitch/TwitchAutomator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { BaseAutomator } from "../Base/BaseAutomator";
import { TwitchChannel } from "./TwitchChannel";
import { TwitchVOD } from "./TwitchVOD";
import { TwitchVODChapter } from "./TwitchVODChapter";
import { LiveStreamDVR } from "@/Core/LiveStreamDVR";

export interface AutomatorMetadata {
message_id: string;
Expand Down Expand Up @@ -713,7 +714,7 @@ export class TwitchAutomator extends BaseAutomator {
}

// streamlink-ttvlol plugin
if (Config.getInstance().cfg("capture.twitch-ttv-lol-plugin")) {
if (Config.getInstance().cfg("capture.twitch-ttv-lol-plugin") && LiveStreamDVR.ttvLolPluginAvailable) {
cmd.push("--plugin-dirs", BaseConfigDataFolder.streamlink_plugins);

if (
Expand Down
26 changes: 26 additions & 0 deletions server/src/Providers/Twitch.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { BaseConfigCacheFolder, BaseConfigDataFolder } from "@/Core/BaseConfig";
import { Config } from "@/Core/Config";
import { Helper } from "@/Core/Helper";
import { KeyValue } from "@/Core/KeyValue";
import { LiveStreamDVR } from "@/Core/LiveStreamDVR";
import { LOGLEVEL, censoredLogWords, log } from "@/Core/Log";
import type { AutomatorMetadata } from "@/Core/Providers/Twitch/TwitchAutomator";
import { TwitchAutomator } from "@/Core/Providers/Twitch/TwitchAutomator";
import { TwitchChannel } from "@/Core/Providers/Twitch/TwitchChannel";
import { execSimple } from "@/Helpers/Execute";
import { getNiceDuration } from "@/Helpers/Format";
import { xClearTimeout, xTimeout } from "@/Helpers/Timeout";
import type { TwitchCommentDumpTD } from "@common/Comments";
Expand Down Expand Up @@ -1502,6 +1504,30 @@ export class TwitchHelper {
return false;
}
}

public static async checkTTVLolPlugin() {

const bin = Helper.path_streamlink();

if (!bin) {
throw new Error("Streamlink binary not found");
}

const args = [
"--twitch-proxy-playlist",
];

const execReturn = await execSimple(bin, args, "streamlink ttv lol plugin check");

const log = execReturn.stdout.join("\n") + "\n" + execReturn.stderr.join("\n");

if (log.includes("unrecognized arguments: --twitch-proxy-playlist")) {
return false;
}

return true;
}

}

/*
Expand Down

0 comments on commit c318595

Please sign in to comment.