mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Adds media library advanced options
This commit is contained in:
1 parent
1c28355197
commit
f89ba4960a
60 files changed
+1877
-51
No files matched your search
@@ -12,6 +12,7 @@ public static partial class ApiRoutes
|
||||
{
|
||||
public const string GET_LIBRARY_BY_ID = "/libraries/{id}";
|
||||
public const string GET_LIBRARIES = "/libraries";
|
||||
public const string GET_ENABLED_LIBRARIES = "/libraries/enabled";
|
||||
public const string ADD_LIBRARY = "/libraries";
|
||||
public const string UPDATE_LIBRARY = "/libraries/{id}";
|
||||
public const string DELETE_LIBRARY = "/libraries/{id}";
|
||||
|
||||
+17
-3
@@ -31,13 +31,21 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
"/media/tv shows/drama/",
|
||||
"/media/tv shows/SCI-FI/",
|
||||
],
|
||||
CoverImage: "/media/posters/myPoster.jpg"
|
||||
CoverImage: "/media/posters/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: false
|
||||
);
|
||||
|
||||
RequestParam(r => r.Title, "The title of the media library. Required.");
|
||||
RequestParam(r => r.LibraryType, "The type of the media library. Required.");
|
||||
RequestParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located. Required.");
|
||||
RequestParam(r => r.CoverImage, "The path of the image file used as the cover for the library. Optional.");
|
||||
RequestParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional.");
|
||||
RequestParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional.");
|
||||
RequestParam(r => r.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
|
||||
@@ -45,10 +53,13 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
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.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
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(201, "The media library was successfuly created.", example:
|
||||
new LibraryResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
@@ -57,11 +68,14 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
|
||||
CoverImage: "/media/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetEnabledLibraries;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetEnabledLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/enabled</c> route.
|
||||
/// </summary>
|
||||
public class GetEnabledLibrariesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly ISender _sender;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetEnabledLibrariesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="sender">Injected service for mediating commands and queries.</param>
|
||||
public GetEnabledLibrariesEndpoint(ISender sender)
|
||||
{
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.GET);
|
||||
Routes(ApiRoutes.Libraries.GET_ENABLED_LIBRARIES);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of enabled media libraries.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<LibraryResponse[]> result = await _sender.Send(new GetEnabledLibrariesQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetEnabledLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetEnabledLibrariesEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetEnabledLibrariesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetEnabledLibrariesEndpointSummary()
|
||||
{
|
||||
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.";
|
||||
|
||||
Response(200, "The media libraries are returned.",
|
||||
example: new LibraryResponse[] {
|
||||
new (
|
||||
Id: Guid.NewGuid(),
|
||||
UserId: Guid.NewGuid(),
|
||||
Title: "TV Shows",
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
|
||||
CoverImage: "/media/myTvShowPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
),
|
||||
new (
|
||||
Id: Guid.NewGuid(),
|
||||
UserId: Guid.NewGuid(),
|
||||
Title: "Movies",
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/movies/"],
|
||||
CoverImage: "/media/myMoviePoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: true,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: true,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
)
|
||||
});
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/enabled"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/enabled"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/enabled"
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -41,9 +41,8 @@ public class GetLibrariesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of libraries.
|
||||
/// Gets the list of media libraries.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the id of the library to be retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
+8
@@ -31,6 +31,10 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
|
||||
CoverImage: "/media/myTvShowPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
),
|
||||
@@ -41,6 +45,10 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/movies/"],
|
||||
CoverImage: "/media/myMoviePoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: true,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: true,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
)
|
||||
|
||||
+8
@@ -36,6 +36,10 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
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.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
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.");
|
||||
|
||||
@@ -46,6 +50,10 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
|
||||
CoverImage: "/media/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
|
||||
+18
-4
@@ -33,7 +33,11 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
"/media/tv shows/drama/",
|
||||
"/media/tv shows/SCI-FI/",
|
||||
],
|
||||
CoverImage: "/media/posters/myPoster.jpg"
|
||||
CoverImage: "/media/posters/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: false
|
||||
);
|
||||
|
||||
RequestParam(r => r.Id, "The Id of the media library. Required.");
|
||||
@@ -42,6 +46,10 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
RequestParam(r => r.LibraryType, "The type of the media library. Required.");
|
||||
RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located. Required.");
|
||||
RequestParam(r => r.CoverImage, "The path of the image file used as the cover for the library. Optional.");
|
||||
RequestParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional.");
|
||||
RequestParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional.");
|
||||
RequestParam(r => r.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
|
||||
@@ -49,10 +57,13 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
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.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
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 library was successfuly updated.", example:
|
||||
new LibraryResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
@@ -60,12 +71,15 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
Title: "TV Shows",
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
|
||||
"/media/myPoster.jpg",
|
||||
CoverImage: "/media/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMedatadaFromWeb: true,
|
||||
SaveMetadataInMediaDirectories: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user