- YouTubeConfiguration.Enabled (default true, Infrastructure): single switch for the whole source - DisabledYouTubeMusicService: null-object IYouTubeMusicService that fails every call with Forbidden, registered instead of the real one when disabled (AddYouTubeMusicService) so no client is ever built - AppSettings.json (Api + Worker): document YouTube.Enabled explicitly; overridable via YouTube__Enabled env var like every other section - CurrentUser.cs: small unrelated cleanup, collapse the IsAuthenticated computation to a single null-coalescing expression Search, albums, stream resolution and adding a new YouTube track all surface as 403 Forbidden through the existing ErrorOr -> HTTP mapping. Daily mix generation already treated a YouTube search failure as "no YouTube candidates" and keeps working with local-only candidates — added a test locking that in. Already-downloaded YouTube tracks are unaffected since playback never goes through IYouTubeMusicService. 257/257 tests passing (7 new), 0 build warnings.
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace Musify.Infrastructure.Configuration
|
|
{
|
|
public class YouTubeConfiguration
|
|
{
|
|
public const string SectionName = "YouTube";
|
|
|
|
/// <summary>Turns the whole YouTube Music source on or off: search, albums, streaming
|
|
/// and adding new YouTube tracks all fail with a clear error while this is <c>false</c>,
|
|
/// and mix generation silently skips YouTube candidates instead of failing.</summary>
|
|
public bool Enabled { get; set; } = true;
|
|
|
|
[Required]
|
|
public string GeographicalLocation { get; set; } = "US";
|
|
|
|
[Range(60, 21600)]
|
|
public int StreamUrlCacheSeconds { get; set; } = 1800;
|
|
|
|
[Range(60, 3600)]
|
|
public int SearchContinuationCacheSeconds { get; set; } = 600;
|
|
|
|
[Range(0, 86400)]
|
|
public int SearchResultsCacheSeconds { get; set; } = 900;
|
|
|
|
[Range(0, 604800)]
|
|
public int SongInfoCacheSeconds { get; set; } = 86400;
|
|
|
|
[Range(32, 720)]
|
|
public int ThumbnailSize { get; set; } = 240;
|
|
|
|
[Range(120, 1080)]
|
|
public int ArtworkSize { get; set; } = 544;
|
|
}
|
|
}
|