using Musify.Application.Contracts; using Musify.Domain.ValueObjects; namespace Musify.Application.Tracks.Responses { /// One item of a combined local/YouTube track listing. Exactly one of /// or is populated: for /// anything already in the catalog (local uploads and YouTube tracks provisioned earlier), /// for a live YouTube Music search hit that has not been /// provisioned yet, so it has no track id. public record TrackSearchItemResponse( TrackSource Source, TrackApplicationResponse? Track, YouTubeSongResult? YouTubeSong) { public static TrackSearchItemResponse FromTrack(TrackApplicationResponse track) => new(track is ExternalTrackApplicationResponse ? TrackSource.YouTube : TrackSource.Local, track, null); public static TrackSearchItemResponse FromYouTubeSong(YouTubeSongResult song) => new(TrackSource.YouTube, null, song); } }