using System.ComponentModel.DataAnnotations;
namespace PLib.Application.Metadata;
/// Where PLib may go looking for information about a video it has on disk.
public sealed class MetadataOptions
{
public const string SectionName = "Metadata";
///
/// The configured sources, in the order they were added. Empty by default: talking to a
/// remote service about the user's files is something they have to ask for.
///
public IList Sources { get; init; } = [];
///
/// How long to wait between requests during a library-wide run. A single lookup is one
/// request and needs no pause; a run over a thousand videos is a thousand, and public
/// instances answer that with a rate limit if it arrives all at once.
///
[Range(0, 10_000)]
public int RequestDelayMilliseconds { get; init; } = 250;
}
/// One GraphQL endpoint that can be asked about a video.
public sealed class MetadataSourceOptions
{
/// What to call it in the interface; the endpoint is no use as a label.
[Required]
public string Name { get; init; } = string.Empty;
/// Absolute URL of the GraphQL endpoint.
[Required]
public string Endpoint { get; init; } = string.Empty;
///
/// Sent as the ApiKey header. Stored in the settings file in plain text — the same
/// place and the same protection the rest of the settings get, which is the file system's.
///
public string ApiKey { get; init; } = string.Empty;
/// False for a source the user has switched off without deleting it.
public bool IsEnabled { get; init; } = true;
/// True when this entry has enough filled in to be worth calling.
public bool IsUsable =>
IsEnabled &&
!string.IsNullOrWhiteSpace(Endpoint) &&
Uri.TryCreate(Endpoint, UriKind.Absolute, out _);
}