Skip to content

Commit

Permalink
check stream status when trying to force record on chapter update
Browse files Browse the repository at this point in the history
related to #466
  • Loading branch information
MrBrax committed Oct 11, 2023
1 parent 0100b3b commit 06be6b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 17 additions & 1 deletion server/src/Core/Providers/Twitch/TwitchAutomator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
7 changes: 7 additions & 0 deletions server/src/Core/Providers/Twitch/TwitchChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,13 @@ export class TwitchChannel extends BaseChannel {
public async isLiveApi(): Promise<boolean> {
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;
}

Expand Down

0 comments on commit 06be6b6

Please sign in to comment.