fix: make sure it is a stream and it is live

This commit is contained in:
Stevan Freeborn
2025-05-27 16:56:38 -05:00
parent c544e33e28
commit 1669bdeebc
3 changed files with 12 additions and 2 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ app.MapPost(ytCallback, static async (HttpContext context, [FromServices] ILogge
return Results.NotFound();
}
if (video.IsStream is false)
if (video.IsLiveStream is false)
{
logger.LogInformation("Video ID {VideoId} is not a live stream.", videoId);
return Results.Ok();
@@ -0,0 +1,7 @@
namespace StevesBot.Webhook.YouTube.Data;
internal sealed record YouTubeSnippet
{
[JsonPropertyName("liveBroadcastContent")]
public string LiveBroadcastContent { get; init; } = string.Empty;
}
@@ -8,5 +8,8 @@ internal sealed record YouTubeVideo
[JsonPropertyName("liveStreamingDetails")]
public YouTubeLiveStreamingDetails? LiveStreamingDetails { get; init; }
public bool IsStream => LiveStreamingDetails is not null;
[JsonPropertyName("snippet")]
public YouTubeSnippet Snippet { get; init; } = new();
public bool IsLiveStream => LiveStreamingDetails is not null && Snippet.LiveBroadcastContent is "live";
}