using ErrorOr;
using Musify.Application.Contracts;
namespace Musify.Infrastructure.Services
{
/// Stands in for when
/// is false,
/// so the source can be turned off without a client ever being constructed. Every read fails
/// with the same error; callers already treat a failed
/// YouTube call as "unavailable" (an HTTP error for direct requests, a skipped candidate for
/// mix generation), so nothing downstream needs to know the source is disabled specifically.
public sealed class DisabledYouTubeMusicService : IYouTubeMusicService
{
private static readonly Error DisabledError =
Error.Forbidden(description: "The YouTube Music source is disabled.");
public Task> SearchSongsAsync(string query, string continuationToken, CancellationToken cancellationToken) =>
Task.FromResult>(DisabledError);
public Task> SearchAlbumsAsync(string query, string continuationToken, CancellationToken cancellationToken) =>
Task.FromResult>(DisabledError);
public Task> GetAlbumAsync(string albumId, CancellationToken cancellationToken) =>
Task.FromResult>(DisabledError);
public Task> GetAudioStreamAsync(string videoId, CancellationToken cancellationToken) =>
Task.FromResult>(DisabledError);
public Task> GetSongAsync(string videoId, CancellationToken cancellationToken) =>
Task.FromResult>(DisabledError);
// Never reached in practice: every caller only reaches this after a successful search or
// song lookup above, neither of which can succeed while disabled. Passing the URL through
// unchanged is the safest thing to do if it's ever called anyway.
public string ResolveArtworkUrl(string thumbnailUrl) => thumbnailUrl;
}
}