95 lines
4.4 KiB
C#
95 lines
4.4 KiB
C#
using PLib.Application.Metadata;
|
|
using PLib.Domain.Videos;
|
|
|
|
namespace PLib.Application.Library;
|
|
|
|
/// <summary>Use cases the UI needs in order to show and refresh the video library.</summary>
|
|
public interface ILibraryService
|
|
{
|
|
/// <summary>Everything currently stored in the library, newest first.</summary>
|
|
Task<IReadOnlyList<VideoItem>> GetLibraryAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Reconciles the library with the configured folders and then fills in metadata and
|
|
/// poster frames for anything that is missing them, streaming progress as it goes.
|
|
/// </summary>
|
|
IAsyncEnumerable<LibraryScanEvent> ScanAsync(
|
|
IReadOnlyList<string> folders,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// What each kind of derived data currently costs, one entry per
|
|
/// <see cref="LibraryDataKind"/>, so the user can see what clearing it would free.
|
|
/// </summary>
|
|
Task<IReadOnlyList<LibraryDataUsage>> GetDataUsageAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Throws the named kinds of derived data away — files as well as the references to them —
|
|
/// so the next scan rebuilds them from scratch. Useful after changing a setting that
|
|
/// governs how they are produced, or when one of them is suspected of being wrong.
|
|
/// </summary>
|
|
Task ResetAsync(LibraryDataKind kinds, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>Remembers where playback stopped so the video can be resumed later.</summary>
|
|
Task SaveProgressAsync(Guid videoId, TimeSpan position, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Groups of videos that look alike, by perceptual hash. Videos without a hash, and
|
|
/// groups of one, are left out.
|
|
/// </summary>
|
|
/// <param name="maxDistance">
|
|
/// How many differing bits still count as the same video. Zero means visually identical;
|
|
/// the useful range for re-encodes is a handful of bits.
|
|
/// </param>
|
|
Task<IReadOnlyList<IReadOnlyList<VideoItem>>> FindDuplicatesAsync(
|
|
int maxDistance,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>One video with its labels loaded, or <c>null</c> if it is gone.</summary>
|
|
Task<VideoItem?> GetVideoWithLabelsAsync(Guid videoId, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>Every tag and collection in the library, alphabetically.</summary>
|
|
Task<IReadOnlyList<LibraryLabel>> GetLabelsAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>Every label with its video count, for the browsing tabs.</summary>
|
|
Task<IReadOnlyList<LabelSummary>> GetLabelSummariesAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Attaches a label to a video, creating it if this is the first time the name is used.
|
|
/// Returns the label, whether it was new or not.
|
|
/// </summary>
|
|
Task<LibraryLabel> AttachLabelAsync(
|
|
Guid videoId,
|
|
string name,
|
|
LabelKind kind,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
Task DetachLabelAsync(Guid videoId, Guid labelId, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Asks every configured metadata source what it has for this video's fingerprint.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Nothing calls this on its own: reaching out to a remote service about the user's files
|
|
/// happens when the user presses the button, and at no other time.
|
|
/// </remarks>
|
|
Task<MetadataLookupResult> FindMetadataAsync(Guid videoId, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Writes a match onto the video: title, description, and a label per tag, performer and
|
|
/// studio. Labels already on the video are kept — applying a match adds, never prunes.
|
|
/// </summary>
|
|
Task ApplyMetadataAsync(
|
|
Guid videoId,
|
|
VideoMetadataMatch match,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Asks the sources about every fingerprinted video in the library, streaming what it
|
|
/// finds. Like the single lookup, it only ever runs because the user started it.
|
|
/// </summary>
|
|
IAsyncEnumerable<MetadataScanEvent> ScanMetadataAsync(
|
|
MetadataScanRequest request,
|
|
CancellationToken cancellationToken = default);
|
|
}
|