Skip to content

Commit

Permalink
- Having failed search for featured Twitch Clips fall back to a non-f…
Browse files Browse the repository at this point in the history
…eatured one if it fails to find an applicable one
  • Loading branch information
Matthew Olivo committed Dec 15, 2024
1 parent aeaf4e0 commit 4114e55
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions MixItUp.Base/Model/Overlay/OverlayTwitchClipV3Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ public async Task<bool> ProcessClip(CommandParametersModel parameters)
{
clip = clips.Where(c => c.thumbnail_url.Contains(ClipThumbnailURLPreviewSegment)).Random();
}

if (clip == null && this.ClipType == OverlayTwitchClipV3ClipType.RandomFeaturedClip)
{
clips = await ServiceManager.Get<TwitchSessionService>().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)
{
Expand All @@ -123,6 +132,15 @@ public async Task<bool> 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<TwitchSessionService>().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))
{
Expand Down

0 comments on commit 4114e55

Please sign in to comment.