Files
Musify/backend/Musify.Application/Contracts/IYouTubeMusicService.cs
T
Admin 07e1daf2ce feat(backend): search albums on YouTube Music
Two read-only endpoints: the album search and the album detail with its
tracklist. Both go through the same single-flight cache as the song search,
and the detail one especially benefits since it costs two upstream calls, the
browse id lookup and the album itself, for metadata that never changes.
Paginator handling is now shared between the song and album searches.
2026-07-20 20:36:28 +02:00

65 lines
2.0 KiB
C#

using ErrorOr;
namespace Musify.Application.Contracts
{
public record YouTubeArtistRef(string? Id, string Name);
public record YouTubeSongResult(
string VideoId,
string Title,
string Artist,
string Album,
int DurationSeconds,
string ThumbnailUrl,
bool IsExplicit,
IReadOnlyList<YouTubeArtistRef> Artists);
public record YouTubeSearchResult(
IReadOnlyList<YouTubeSongResult> Items,
string ContinuationToken);
public record YouTubeAlbumResult(
string AlbumId,
string Title,
string Artist,
string ThumbnailUrl,
int? ReleaseYear,
bool IsSingle,
bool IsEp,
IReadOnlyList<YouTubeArtistRef> Artists);
public record YouTubeAlbumSearchResult(
IReadOnlyList<YouTubeAlbumResult> Items,
string ContinuationToken);
public record YouTubeAlbumTrack(
string VideoId,
string Title,
int DurationSeconds,
int TrackNumber,
bool IsExplicit);
public record YouTubeAlbumDetail(
YouTubeAlbumResult Album,
string Description,
int TotalDurationSeconds,
IReadOnlyList<YouTubeAlbumTrack> Tracks);
public record YouTubeStreamInfo(string Url, int ExpiresInSeconds);
public interface IYouTubeMusicService
{
Task<ErrorOr<YouTubeSearchResult>> SearchSongsAsync(string query, string continuationToken, CancellationToken cancellationToken);
Task<ErrorOr<YouTubeAlbumSearchResult>> SearchAlbumsAsync(string query, string continuationToken, CancellationToken cancellationToken);
Task<ErrorOr<YouTubeAlbumDetail>> GetAlbumAsync(string albumId, CancellationToken cancellationToken);
Task<ErrorOr<YouTubeStreamInfo>> GetAudioStreamAsync(string videoId, CancellationToken cancellationToken);
Task<ErrorOr<YouTubeSongResult>> GetSongAsync(string videoId, CancellationToken cancellationToken);
string ResolveArtworkUrl(string thumbnailUrl);
}
}