mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds dynamic path templates for media libraries, so that the scanner can derive the meaning of each path part
This commit is contained in:
1 parent
62b0e9297a
commit
ca4f308b0a
86 files changed
+7406
-151
No files matched your search
@@ -28,6 +28,7 @@ public static partial class ApiRoutes
|
||||
public const string GET_LIBRARY_ARTWORK_PROVIDERS = "/libraries/{libraryId}/artwork-providers";
|
||||
public const string SET_LIBRARY_ARTWORK_PROVIDER_ENABLED = "/libraries/{libraryId}/artwork-providers/{pluginId}/enabled";
|
||||
public const string REORDER_LIBRARY_ARTWORK_PROVIDERS = "/libraries/{libraryId}/artwork-providers/reorder";
|
||||
public const string GET_LIBRARY_PATH_TEMPLATE_PARTS = "/libraries/path-template-parts/{libraryType}";
|
||||
public const string GET_LIBRARY_BOOK_READERS = "/libraries/{libraryId}/book-readers";
|
||||
public const string SET_LIBRARY_BOOK_READER_ENABLED = "/libraries/{libraryId}/book-readers/{pluginId}/enabled";
|
||||
}
|
||||
|
||||
+5
-1
@@ -36,7 +36,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
IsLocked: false,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: null
|
||||
);
|
||||
|
||||
RequestParam(r => r.Title, "The title of the media library. Required.");
|
||||
@@ -48,6 +49,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
RequestParam(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.");
|
||||
RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
@@ -60,6 +62,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
|
||||
@@ -76,6 +79,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
|
||||
+17
@@ -22,6 +22,21 @@ public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEnd
|
||||
Summary = "Retrieves the list of enabled media libraries.";
|
||||
Description = "Retrieves the entire list of media libraries that are marked as enabled, if the user making the request is an Admin, or just the library owned by them, for regular users.";
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
ResponseParam<LibraryResponse>(r => r.CoverImage, "The path of the image file used as the cover for the library.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.");
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
|
||||
Response(200, "The media libraries are returned.",
|
||||
example: new LibraryResponse[] {
|
||||
new (
|
||||
@@ -36,6 +51,7 @@ public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEnd
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
),
|
||||
@@ -51,6 +67,7 @@ public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEnd
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: true,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
)
|
||||
|
||||
+17
@@ -22,6 +22,21 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
Summary = "Retrieves the list of media libraries.";
|
||||
Description = "Retrieves the entire list of media libraries, if the user making the request is an Admin, or just the library owned by them, for regular users.";
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
ResponseParam<LibraryResponse>(r => r.CoverImage, "The path of the image file used as the cover for the library.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.");
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
|
||||
Response(200, "The media libraries are returned.",
|
||||
example: new LibraryResponse[] {
|
||||
new (
|
||||
@@ -36,6 +51,7 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
),
|
||||
@@ -51,6 +67,7 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: true,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
)
|
||||
|
||||
+2
@@ -41,6 +41,7 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
|
||||
@@ -56,6 +57,7 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetLibraryPathTemplateParts;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/path-template-parts/{libraryType}</c> route.
|
||||
/// </summary>
|
||||
public class GetLibraryPathTemplatePartsEndpoint : BaseEndpoint<GetLibraryPathTemplatePartsRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetLibraryPathTemplatePartsQuery, Result<LibraryPathTemplateCatalogResponse>> _getLibraryPathTemplatePartsQueryHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryPathTemplatePartsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="getLibraryPathTemplatePartsQueryHandler">Injected service for handling get library path template parts queries.</param>
|
||||
public GetLibraryPathTemplatePartsEndpoint(IQueryHandler<GetLibraryPathTemplatePartsQuery, Result<LibraryPathTemplateCatalogResponse>> getLibraryPathTemplatePartsQueryHandler)
|
||||
{
|
||||
_getLibraryPathTemplatePartsQueryHandler = getLibraryPathTemplatePartsQueryHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.GET);
|
||||
Routes(ApiRoutes.Libraries.GET_LIBRARY_PATH_TEMPLATE_PARTS);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path parts available for a media library type.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the media library type whose available path parts are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetLibraryPathTemplatePartsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<LibraryPathTemplateCatalogResponse> result = await _getLibraryPathTemplatePartsQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -38,7 +38,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
IsLocked: false,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: null
|
||||
);
|
||||
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library. Required.");
|
||||
@@ -52,6 +53,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
RequestParam(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.");
|
||||
RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
@@ -64,6 +66,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
|
||||
@@ -80,6 +83,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
PathTemplateParts: [],
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
|
||||
Reference in new issue
Block a user