From 3481dcdd5b9b086da22dc381be5fa4f0f2ccdc25 Mon Sep 17 00:00:00 2001 From: Braxen Date: Sun, 26 Nov 2023 18:43:49 +0100 Subject: [PATCH] small comments and var namings --- .../src/Core/Providers/Base/BaseAutomator.ts | 24 +++++++++++++++++++ .../Core/Providers/Twitch/TwitchAutomator.ts | 14 +++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/server/src/Core/Providers/Base/BaseAutomator.ts b/server/src/Core/Providers/Base/BaseAutomator.ts index fb5f43da..8d669b2f 100644 --- a/server/src/Core/Providers/Base/BaseAutomator.ts +++ b/server/src/Core/Providers/Base/BaseAutomator.ts @@ -273,6 +273,11 @@ export class BaseAutomator { return await Promise.resolve(false); } + /** + * Notifies the chapter change to the providers. + * + * @param channel - The Twitch channel. + */ public notifyChapterChange(channel: TwitchChannel) { const vod = channel.latest_vod; if (!vod) return; @@ -762,6 +767,12 @@ export class BaseAutomator { this.vod_absolute_episode = s.absolute_stream_number; } + /** + * Starts the capture of the stream. + * @param tries The number of download attempts made (optional, default is 0). + * @returns A Promise that resolves to a boolean indicating whether the download was successful. + * @throws An error if the channel is not found, no VOD ID is supplied, or if the download fails. + */ public async download(tries = 0): Promise { // const data_title = this.getTitle(); const dataStarted = this.getStartDate(); @@ -1273,10 +1284,23 @@ export class BaseAutomator { return true; } + /** + * Returns an array of provider arguments. + * Override this method to add custom arguments. + * + * @returns {string[]} The provider arguments. + */ public providerArgs(): string[] { return []; } + /** + * A function to do things with the incoming log data from streamlink. + * For example, check for errors or ad-breaks. + * + * @param source - The source of the data, either "stdout" or "stderr". + * @param data - The ticker data received from the streamlink. + */ public captureTicker(source: "stdout" | "stderr", data: string) { if (data == null || data == undefined || typeof data !== "string") { log( diff --git a/server/src/Core/Providers/Twitch/TwitchAutomator.ts b/server/src/Core/Providers/Twitch/TwitchAutomator.ts index 33f8fbfa..6632c0ee 100644 --- a/server/src/Core/Providers/Twitch/TwitchAutomator.ts +++ b/server/src/Core/Providers/Twitch/TwitchAutomator.ts @@ -284,12 +284,12 @@ export class TwitchAutomator extends BaseAutomator { return false; } - const capture_vod = TwitchVOD.getVodByCaptureId(event.id); - if (capture_vod) { + const captureVodCheck = TwitchVOD.getVodByCaptureId(event.id); + if (captureVodCheck) { log( LOGLEVEL.INFO, "automator.handle", - `Channel ${this.broadcaster_user_login} online, but vod ${event.id} already exists (${capture_vod.basename}), skipping` + `Channel ${this.broadcaster_user_login} online, but vod ${event.id} already exists (${captureVodCheck.basename}), skipping` ); this.fallbackCapture() .then(() => { @@ -454,7 +454,7 @@ export class TwitchAutomator extends BaseAutomator { ); return false; } - event = this.payload_eventsub.event as ChannelUpdateEvent; + event = this.payload_eventsub.event; chapterData = await this.getChapterData(event); } else { log( @@ -774,12 +774,12 @@ export class TwitchAutomator extends BaseAutomator { ); } - const proxy_match = data.match(/Using playlist proxy: '(.*)'/); - if (proxy_match) { + const proxyMatch = data.match(/Using playlist proxy: '(.*)'/); + if (proxyMatch) { log( LOGLEVEL.INFO, "automator.captureVideo", - `Using playlist proxy: ${proxy_match[1]}` + `Using playlist proxy: ${proxyMatch[1]}` ); } }