From 4114e55d8b4647a41a5202d4b0f63029b0dae23e Mon Sep 17 00:00:00 2001 From: Matthew Olivo Date: Sun, 15 Dec 2024 15:35:18 -0800 Subject: [PATCH] - Having failed search for featured Twitch Clips fall back to a non-featured one if it fails to find an applicable one --- .../Model/Overlay/OverlayTwitchClipV3Model.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MixItUp.Base/Model/Overlay/OverlayTwitchClipV3Model.cs b/MixItUp.Base/Model/Overlay/OverlayTwitchClipV3Model.cs index 6adc629bc..df37ca736 100644 --- a/MixItUp.Base/Model/Overlay/OverlayTwitchClipV3Model.cs +++ b/MixItUp.Base/Model/Overlay/OverlayTwitchClipV3Model.cs @@ -113,6 +113,15 @@ public async Task ProcessClip(CommandParametersModel parameters) { clip = clips.Where(c => c.thumbnail_url.Contains(ClipThumbnailURLPreviewSegment)).Random(); } + + if (clip == null && this.ClipType == OverlayTwitchClipV3ClipType.RandomFeaturedClip) + { + clips = await ServiceManager.Get().UserConnection.GetClips(twitchUser, featured: false, maxResults: 500); + if (clips != null && clips.Count() > 0) + { + clip = clips.Where(c => c.thumbnail_url.Contains(ClipThumbnailURLPreviewSegment)).Random(); + } + } } else if (this.ClipType == OverlayTwitchClipV3ClipType.LatestClip || this.ClipType == OverlayTwitchClipV3ClipType.LatestFeaturedClip) { @@ -123,6 +132,15 @@ public async Task ProcessClip(CommandParametersModel parameters) { clip = clips.Where(c => c.thumbnail_url.Contains(ClipThumbnailURLPreviewSegment)).OrderByDescending(c => c.created_at).FirstOrDefault(); } + + if (clip == null && this.ClipType == OverlayTwitchClipV3ClipType.LatestFeaturedClip) + { + clips = await ServiceManager.Get().UserConnection.GetClips(twitchUser, startDate: startDate, endDate: DateTimeOffset.Now, featured: false, maxResults: 500); + if (clips != null && clips.Count() > 0) + { + clip = clips.Where(c => c.thumbnail_url.Contains(ClipThumbnailURLPreviewSegment)).OrderByDescending(c => c.created_at).FirstOrDefault(); + } + } } else if (this.ClipType == OverlayTwitchClipV3ClipType.SpecificClip && !string.IsNullOrEmpty(clipReferenceID)) {