From 06be6b6a0f6863e21914dfdaef6b6e9a0f2421f8 Mon Sep 17 00:00:00 2001 From: "CATERPILLAR\\Braxen" Date: Wed, 11 Oct 2023 12:48:34 +0200 Subject: [PATCH] check stream status when trying to force record on chapter update related to #466 --- .../Core/Providers/Twitch/TwitchAutomator.ts | 18 +++++++++++++++++- .../src/Core/Providers/Twitch/TwitchChannel.ts | 7 +++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/server/src/Core/Providers/Twitch/TwitchAutomator.ts b/server/src/Core/Providers/Twitch/TwitchAutomator.ts index ad25cca3..0b723a94 100644 --- a/server/src/Core/Providers/Twitch/TwitchAutomator.ts +++ b/server/src/Core/Providers/Twitch/TwitchAutomator.ts @@ -619,8 +619,24 @@ export class TwitchAutomator extends BaseAutomator { log( LOGLEVEL.INFO, "automator.updateGame", - `Channel ${this.getLogin()} status is online but not capturing, starting capture from chapter update.` + `Channel ${this.getLogin()} status is online but not capturing, checking if we can start downloading.` ); + + /** + * After a stream ends, the streamer can still change the stream title or game. + * This will trigger an updateGame event, but we don't want to start downloading again if the stream is not live. + * @TODO: check for false positives + */ + if (!(await this.channel?.isLiveApi())) { + log( + LOGLEVEL.WARNING, + "automator.updateGame", + `Channel ${this.getLogin()} is not live, won't start downloading. ` + + `This might be caused by the streamer changing the stream title or game after ending the stream.` + ); + return false; + } + this.download(); } } diff --git a/server/src/Core/Providers/Twitch/TwitchChannel.ts b/server/src/Core/Providers/Twitch/TwitchChannel.ts index 3f688ed7..021e298c 100644 --- a/server/src/Core/Providers/Twitch/TwitchChannel.ts +++ b/server/src/Core/Providers/Twitch/TwitchChannel.ts @@ -1098,6 +1098,13 @@ export class TwitchChannel extends BaseChannel { public async isLiveApi(): Promise { if (!this.internalId) return false; const streams = await TwitchChannel.getStreams(this.internalId); + log( + LOGLEVEL.DEBUG, + "tw.channel.isLiveApi", + `Checking if channel ${this.internalName} is live: ${ + streams ? streams.length : 0 + } streams found` + ); return streams && streams.length > 0; }