51 lines
2.0 KiB
C#
51 lines
2.0 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace PLib.Application.Metadata;
|
|
|
|
/// <summary>Where PLib may go looking for information about a video it has on disk.</summary>
|
|
public sealed class MetadataOptions
|
|
{
|
|
public const string SectionName = "Metadata";
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public IList<MetadataSourceOptions> Sources { get; init; } = [];
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
[Range(0, 10_000)]
|
|
public int RequestDelayMilliseconds { get; init; } = 250;
|
|
}
|
|
|
|
/// <summary>One GraphQL endpoint that can be asked about a video.</summary>
|
|
public sealed class MetadataSourceOptions
|
|
{
|
|
/// <summary>What to call it in the interface; the endpoint is no use as a label.</summary>
|
|
[Required]
|
|
public string Name { get; init; } = string.Empty;
|
|
|
|
/// <summary>Absolute URL of the GraphQL endpoint.</summary>
|
|
[Required]
|
|
public string Endpoint { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Sent as the <c>ApiKey</c> 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.
|
|
/// </summary>
|
|
public string ApiKey { get; init; } = string.Empty;
|
|
|
|
/// <summary>False for a source the user has switched off without deleting it.</summary>
|
|
public bool IsEnabled { get; init; } = true;
|
|
|
|
/// <summary>True when this entry has enough filled in to be worth calling.</summary>
|
|
public bool IsUsable =>
|
|
IsEnabled &&
|
|
!string.IsNullOrWhiteSpace(Endpoint) &&
|
|
Uri.TryCreate(Endpoint, UriKind.Absolute, out _);
|
|
}
|