mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +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
@@ -38,6 +38,9 @@
|
||||
- [Cancel Library Scan](#cancel-library-scan)
|
||||
- [Cancel Library Scan Request](#cancel-library-scan-request)
|
||||
- [Cancel Library Scan Response](#cancel-library-scan-response)
|
||||
- [Get Library Path Template Parts](#get-library-path-template-parts)
|
||||
- [Get Library Path Template Parts Request](#get-library-path-template-parts-request)
|
||||
- [Get Library Path Template Parts Response](#get-library-path-template-parts-response)
|
||||
|
||||
## Library
|
||||
|
||||
@@ -59,9 +62,10 @@ POST api/v1/libraries
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": []
|
||||
}
|
||||
```
|
||||
|
||||
@@ -83,9 +87,10 @@ POST api/v1/libraries
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
}
|
||||
@@ -118,9 +123,10 @@ GET api/v1/libraries
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
}
|
||||
@@ -154,9 +160,10 @@ GET api/v1/libraries/enabled
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
}
|
||||
@@ -189,9 +196,10 @@ GET api/v1/libraries/{id}
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
}
|
||||
@@ -217,9 +225,10 @@ PUT api/v1/libraries/{id}
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": []
|
||||
}
|
||||
```
|
||||
|
||||
@@ -241,9 +250,10 @@ PUT api/v1/libraries/{id}
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
}
|
||||
@@ -400,3 +410,43 @@ POST api/v1/libraries/{libraryId}/scans/{scanId}/cancel
|
||||
```js
|
||||
204 No Content
|
||||
```
|
||||
|
||||
### Get Library Path Template Parts
|
||||
|
||||
#### Get Library Path Template Parts Request
|
||||
|
||||
```js
|
||||
GET api/v1/libraries/path-template-parts/{libraryType}
|
||||
```
|
||||
|
||||
#### Get Library Path Template Parts Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"parts": [
|
||||
{
|
||||
"kind": "Artist",
|
||||
"valueType": "Text",
|
||||
"defaultRepresentation": "{0}",
|
||||
"isOptionalByDefault": false
|
||||
},
|
||||
{
|
||||
"kind": "DiscNumber",
|
||||
"valueType": "Integer",
|
||||
"defaultRepresentation": "{0:00}",
|
||||
"isOptionalByDefault": true
|
||||
}
|
||||
],
|
||||
"defaultTemplateParts": [
|
||||
{
|
||||
"kind": "Artist",
|
||||
"representation": "{0}",
|
||||
"isOptional": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -11,7 +11,11 @@ Content-Type: application/json
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": [
|
||||
{ "kind": "Artist", "representation": "{0}", "isOptional": false },
|
||||
{ "kind": "Separator", "representation": "", "isOptional": false }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
GET {{host}}/api/v1/libraries/path-template-parts/Music
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -13,7 +13,11 @@ Content-Type: application/json
|
||||
"coverImage": null,
|
||||
"isEnabled": true,
|
||||
"isLocked": false,
|
||||
"downloadMetadataFromWeb": true,
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"pathTemplateParts": [
|
||||
{ "kind": "Artist", "representation": "{0}", "isOptional": false },
|
||||
{ "kind": "Separator", "representation": "", "isOptional": false }
|
||||
]
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for one part of the path template of a media library, carried by the commands that create or update a media library.
|
||||
/// </summary>
|
||||
/// <param name="Kind">The kind of the path part.</param>
|
||||
/// <param name="Representation">The literal text or the value mask of the path part.</param>
|
||||
/// <param name="IsOptional">Whether the path part can be absent from the path.</param>
|
||||
public record LibraryPathTemplatePartDto(
|
||||
string? Kind,
|
||||
string? Representation,
|
||||
bool IsOptional
|
||||
);
|
||||
+11
@@ -45,6 +45,11 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public required ICollection<LibraryContentLocationEntity> ContentLocations { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ordered parts of the template describing the structure of the media library on disk.
|
||||
/// </summary>
|
||||
public ICollection<LibraryPathTemplatePartEntity> PathTemplateParts { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of scans of the media library.
|
||||
/// </summary>
|
||||
@@ -87,6 +92,12 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public string? ArtworkProvidersConfigurationFingerprint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fingerprint of the path template of the media library, used to detect whether the template
|
||||
/// changed since the last scan, and thus whether the metadata needs to be derived from the paths again.
|
||||
/// </summary>
|
||||
public string? PathTemplateFingerprint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user that owns the media library.
|
||||
/// </summary>
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for one part of the path template of a media library.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Kind: {Kind}; Position: {Position}")]
|
||||
public class LibraryPathTemplatePartEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the zero based position of the part in the path template.
|
||||
/// </summary>
|
||||
public required int Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of the path part.
|
||||
/// </summary>
|
||||
public required LibraryPathPartKind Kind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the literal text or the value mask of the path part.
|
||||
/// </summary>
|
||||
public required string Representation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the path part can be absent from the path.
|
||||
/// </summary>
|
||||
public required bool IsOptional { get; set; }
|
||||
}
|
||||
+4
-1
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
@@ -26,7 +28,8 @@ public static class AddMediaLibraryRequestMapping
|
||||
request.IsLocked,
|
||||
request.CanDownloadMetadataFromWeb,
|
||||
request.ShouldSaveMetadataInMediaDirectories,
|
||||
request.ShouldSkipUnchangedDirectoriesDuringScan
|
||||
request.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
request.PathTemplateParts?.Select(part => new LibraryPathTemplatePartDto(part.Kind, part.Representation, part.IsOptional)).ToArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetLibraryPathTemplatePartsRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetLibraryPathTemplatePartsRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetLibraryPathTemplatePartsQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetLibraryPathTemplatePartsQuery ToQuery(this GetLibraryPathTemplatePartsRequest request)
|
||||
{
|
||||
return new GetLibraryPathTemplatePartsQuery(
|
||||
request.LibraryType
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,9 @@ public static class LibraryEntityMapping
|
||||
repositoryEntity.CanDownloadMetadataFromWeb,
|
||||
repositoryEntity.ShouldSaveMetadataInMediaDirectories,
|
||||
repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
[.. repositoryEntity.PathTemplateParts
|
||||
.OrderBy(part => part.Position)
|
||||
.Select(part => new LibraryPathTemplatePartResponse(part.Kind.ToString(), part.Representation, part.IsOptional))],
|
||||
repositoryEntity.CreatedOnUtc,
|
||||
repositoryEntity.UpdatedOnUtc
|
||||
);
|
||||
@@ -50,6 +53,10 @@ public static class LibraryEntityMapping
|
||||
/// </returns>
|
||||
public static Result<Library> ToDomainEntity(this LibraryEntity repositoryEntity)
|
||||
{
|
||||
Result<LibraryPathTemplate> pathTemplateResult = BuildPathTemplate(repositoryEntity.PathTemplateParts);
|
||||
if (pathTemplateResult.IsFailure)
|
||||
return pathTemplateResult.Errors;
|
||||
|
||||
return Library.Create(
|
||||
LibraryId.Create(repositoryEntity.Id),
|
||||
UserId.Create(repositoryEntity.UserId),
|
||||
@@ -62,10 +69,31 @@ public static class LibraryEntityMapping
|
||||
repositoryEntity.CanDownloadMetadataFromWeb,
|
||||
repositoryEntity.ShouldSaveMetadataInMediaDirectories,
|
||||
repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplateResult.Value,
|
||||
[.. repositoryEntity.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))]
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the path template of a media library from its ordered stored parts.
|
||||
/// </summary>
|
||||
/// <param name="parts">The stored parts of the path template.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either the built <see cref="LibraryPathTemplate"/>, or an error message.
|
||||
/// </returns>
|
||||
private static Result<LibraryPathTemplate> BuildPathTemplate(IEnumerable<LibraryPathTemplatePartEntity> parts)
|
||||
{
|
||||
List<LibraryPathPart> orderedParts = [];
|
||||
foreach (LibraryPathTemplatePartEntity part in parts.OrderBy(part => part.Position))
|
||||
{
|
||||
Result<LibraryPathPart> partResult = LibraryPathPart.Create(part.Kind, part.Representation, part.IsOptional);
|
||||
if (partResult.IsFailure)
|
||||
return partResult.Errors;
|
||||
orderedParts.Add(partResult.Value);
|
||||
}
|
||||
return LibraryPathTemplate.Create(orderedParts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Library"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -26,6 +26,13 @@ public static class LibraryMapping
|
||||
LibraryType = domainEntity.LibraryType,
|
||||
UserId = domainEntity.UserId.Value,
|
||||
ContentLocations = [.. domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path })],
|
||||
PathTemplateParts = [.. domainEntity.PathTemplate.Parts.Select((part, index) => new LibraryPathTemplatePartEntity
|
||||
{
|
||||
Kind = part.Kind,
|
||||
Representation = part.Representation,
|
||||
IsOptional = part.IsOptional,
|
||||
Position = index
|
||||
})],
|
||||
CoverImage = domainEntity.CoverImage.HasValue ? domainEntity.CoverImage.Value : null,
|
||||
IsEnabled = domainEntity.IsEnabled,
|
||||
IsLocked = domainEntity.IsLocked,
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="LibraryPathTemplatePartDto"/>.
|
||||
/// </summary>
|
||||
public static class LibraryPathTemplatePartDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the provided path template parts to their domain path parts.
|
||||
/// </summary>
|
||||
/// <param name="parts">The path template parts to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either the converted domain path parts, or an error message.
|
||||
/// </returns>
|
||||
public static Result<IReadOnlyList<LibraryPathPart>> ToDomainParts(this IEnumerable<LibraryPathTemplatePartDto>? parts)
|
||||
{
|
||||
List<LibraryPathPart> domainParts = [];
|
||||
if (parts is null)
|
||||
return domainParts;
|
||||
|
||||
foreach (LibraryPathTemplatePartDto part in parts)
|
||||
{
|
||||
if (!Enum.TryParse(part.Kind, ignoreCase: true, out LibraryPathPartKind kind))
|
||||
return DomainErrors.Library.PathTemplatePartKindNotSupportedForLibraryType;
|
||||
|
||||
Result<LibraryPathPart> partResult = LibraryPathPart.Create(kind, part.Representation, part.IsOptional);
|
||||
if (partResult.IsFailure)
|
||||
return partResult.Errors;
|
||||
|
||||
domainParts.Add(partResult.Value);
|
||||
}
|
||||
return domainParts;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
@@ -28,7 +30,8 @@ public static class UpdateLibraryRequestMapping
|
||||
request.IsLocked,
|
||||
request.CanDownloadMetadataFromWeb,
|
||||
request.ShouldSaveMetadataInMediaDirectories,
|
||||
request.ShouldSkipUnchangedDirectoriesDuringScan
|
||||
request.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
request.PathTemplateParts?.Select(part => new LibraryPathTemplatePartDto(part.Kind, part.Representation, part.IsOptional)).ToArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="PathTemplateParts">The ordered parts of the template describing the structure of the media library on disk.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record AddLibraryCommand(
|
||||
string? Title,
|
||||
@@ -27,5 +29,6 @@ public record AddLibraryCommand(
|
||||
bool IsLocked,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryPathTemplatePartDto[]? PathTemplateParts
|
||||
) : ICommand;
|
||||
+22
-2
@@ -11,6 +11,8 @@ using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
@@ -39,6 +41,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
private readonly IEnvironmentContext _environmentContext;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IMediaLibraryProviderConfigurationStore _providerConfigurationStore;
|
||||
private readonly ILibraryPathTemplateService _pathTemplateService;
|
||||
private readonly IValidator<AddLibraryCommand> _validator;
|
||||
|
||||
/// <summary>
|
||||
@@ -49,6 +52,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
/// <param name="domainEventsQueue">Injected service for the queue of domain events.</param>
|
||||
/// <param name="environmentContext">Injected facade service for environment contextual services.</param>
|
||||
/// <param name="providerConfigurationStore">Injected store of the provider configurations of the media libraries.</param>
|
||||
/// <param name="pathTemplateService">Injected service for validating and resolving the path templates of the media libraries.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
/// <param name="validator">Injected validator for application validation rules.</param>
|
||||
public AddLibraryCommandHandler(
|
||||
@@ -57,6 +61,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
IDomainEventsQueue domainEventsQueue,
|
||||
IEnvironmentContext environmentContext,
|
||||
IMediaLibraryProviderConfigurationStore providerConfigurationStore,
|
||||
ILibraryPathTemplateService pathTemplateService,
|
||||
IUnitOfWork unitOfWork,
|
||||
IValidator<AddLibraryCommand> validator)
|
||||
{
|
||||
@@ -66,6 +71,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
_environmentContext = environmentContext;
|
||||
_authorizationService = authorizationService;
|
||||
_providerConfigurationStore = providerConfigurationStore;
|
||||
_pathTemplateService = pathTemplateService;
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
@@ -108,11 +114,24 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
return DomainErrors.Library.CoverFileMustBeAnImage;
|
||||
}
|
||||
|
||||
LibraryType libraryType = Enum.Parse<LibraryType>(command.LibraryType!);
|
||||
|
||||
// A library always carries a path template: the one provided by the user, or the ideal structure of the library type as its default.
|
||||
Result<IReadOnlyList<LibraryPathPart>> pathTemplatePartsResult = command.PathTemplateParts.ToDomainParts();
|
||||
if (pathTemplatePartsResult.IsFailure)
|
||||
return pathTemplatePartsResult.Errors;
|
||||
LibraryPathTemplate pathTemplate = command.PathTemplateParts is null
|
||||
? _pathTemplateService.GetDefaultTemplate(libraryType)
|
||||
: LibraryPathTemplate.Create(pathTemplatePartsResult.Value);
|
||||
Result<Success> validatePathTemplateResult = _pathTemplateService.Validate(libraryType, pathTemplate);
|
||||
if (validatePathTemplateResult.IsFailure)
|
||||
return validatePathTemplateResult.Errors;
|
||||
|
||||
// Create a domain library object.
|
||||
Result<Library> createLibraryResult = Library.Create(
|
||||
UserId.Create(userId),
|
||||
command.Title!,
|
||||
Enum.Parse<LibraryType>(command.LibraryType!),
|
||||
libraryType,
|
||||
command.ContentLocations!,
|
||||
Optional<string>.FromNullable(command.CoverImage),
|
||||
command.IsEnabled,
|
||||
@@ -120,6 +139,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
command.CanDownloadMetadataFromWeb,
|
||||
command.ShouldSaveMetadataInMediaDirectories,
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplate,
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -134,7 +154,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
if (insertLibraryResult.IsFailure)
|
||||
return insertLibraryResult.Errors;
|
||||
Result<Success> ensureProviderConfigurationsResult = await _providerConfigurationStore.EnsureProviderConfigurationsAsync(
|
||||
createLibraryResult.Value.Id.Value, Enum.Parse<LibraryType>(command.LibraryType!), cancellationToken).ConfigureAwait(false);
|
||||
createLibraryResult.Value.Id.Value, libraryType, cancellationToken).ConfigureAwait(false);
|
||||
if (ensureProviderConfigurationsResult.IsFailure)
|
||||
return ensureProviderConfigurationsResult.Errors;
|
||||
|
||||
|
||||
+12
@@ -41,5 +41,17 @@ public class AddLibraryCommandValidator : AbstractValidator<AddLibraryCommand>
|
||||
.WithError(Errors.Library.TitleCannotBeEmpty)
|
||||
.MaximumLength(255)
|
||||
.WithError(Errors.Library.TitleMustBeMaximum255CharactersLong);
|
||||
|
||||
RuleForEach(command => command.PathTemplateParts)
|
||||
.ChildRules(part =>
|
||||
{
|
||||
part.RuleFor(pathPart => pathPart.Kind)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Library.PathTemplatePartKindNotSupportedForLibraryType);
|
||||
part.RuleFor(pathPart => pathPart.Representation)
|
||||
.NotEmpty()
|
||||
.When(pathPart => !string.Equals(pathPart.Kind, nameof(LibraryPathPartKind.Separator), StringComparison.OrdinalIgnoreCase))
|
||||
.WithError(Errors.Library.PathTemplateLiteralCannotBeEmpty);
|
||||
});
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -20,6 +21,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="PathTemplateParts">The ordered parts of the template describing the structure of the media library on disk.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record UpdateLibraryCommand(
|
||||
Guid Id,
|
||||
@@ -32,5 +34,6 @@ public record UpdateLibraryCommand(
|
||||
bool IsLocked,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryPathTemplatePartDto[]? PathTemplateParts
|
||||
) : ICommand;
|
||||
+18
@@ -12,6 +12,7 @@ using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
@@ -43,6 +44,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
private readonly IDomainEventsQueue _domainEventsQueue;
|
||||
private readonly IEnvironmentContext _environmentContext;
|
||||
private readonly IMediaLibraryProviderConfigurationStore _providerConfigurationStore;
|
||||
private readonly ILibraryPathTemplateService _pathTemplateService;
|
||||
private readonly IValidator<UpdateLibraryCommand> _validator;
|
||||
|
||||
/// <summary>
|
||||
@@ -53,6 +55,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
/// <param name="domainEventsQueue">Injected service for the queue of domain events.</param>
|
||||
/// <param name="environmentContext">Injected facade service for environment contextual services.</param>
|
||||
/// <param name="providerConfigurationStore">Injected store of the provider configurations of the media libraries.</param>
|
||||
/// <param name="pathTemplateService">Injected service for validating and resolving the path templates of the media libraries.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
/// <param name="validator">Injected validator for application validation rules.</param>
|
||||
public UpdateLibraryCommandHandler(
|
||||
@@ -61,6 +64,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
IDomainEventsQueue domainEventsQueue,
|
||||
IEnvironmentContext environmentContext,
|
||||
IMediaLibraryProviderConfigurationStore providerConfigurationStore,
|
||||
ILibraryPathTemplateService pathTemplateService,
|
||||
IUnitOfWork unitOfWork,
|
||||
IValidator<UpdateLibraryCommand> validator)
|
||||
{
|
||||
@@ -70,6 +74,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
_domainEventsQueue = domainEventsQueue;
|
||||
_environmentContext = environmentContext;
|
||||
_providerConfigurationStore = providerConfigurationStore;
|
||||
_pathTemplateService = pathTemplateService;
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
@@ -124,6 +129,18 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
|
||||
// Create a domain library object.
|
||||
LibraryType newLibraryType = Enum.Parse<LibraryType>(command.LibraryType!);
|
||||
|
||||
// A library always carries a path template: the one provided by the user, or the ideal structure of the library type as its default.
|
||||
Result<IReadOnlyList<LibraryPathPart>> pathTemplatePartsResult = command.PathTemplateParts.ToDomainParts();
|
||||
if (pathTemplatePartsResult.IsFailure)
|
||||
return pathTemplatePartsResult.Errors;
|
||||
LibraryPathTemplate pathTemplate = command.PathTemplateParts is null
|
||||
? _pathTemplateService.GetDefaultTemplate(newLibraryType)
|
||||
: LibraryPathTemplate.Create(pathTemplatePartsResult.Value);
|
||||
Result<Success> validatePathTemplateResult = _pathTemplateService.Validate(newLibraryType, pathTemplate);
|
||||
if (validatePathTemplateResult.IsFailure)
|
||||
return validatePathTemplateResult.Errors;
|
||||
|
||||
Result<Library> createLibraryResult = Library.Create(
|
||||
LibraryId.Create(command.Id),
|
||||
UserId.Create(command.OwnerId),
|
||||
@@ -136,6 +153,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
command.CanDownloadMetadataFromWeb,
|
||||
command.ShouldSaveMetadataInMediaDirectories,
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplate,
|
||||
[.. getLibraryResult.Value.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))]
|
||||
);
|
||||
if (createLibraryResult.IsFailure)
|
||||
|
||||
+12
@@ -53,5 +53,17 @@ public class UpdateLibraryCommandValidator : AbstractValidator<UpdateLibraryComm
|
||||
.WithError(Errors.Library.TitleCannotBeEmpty)
|
||||
.MaximumLength(255)
|
||||
.WithError(Errors.Library.TitleMustBeMaximum255CharactersLong);
|
||||
|
||||
RuleForEach(command => command.PathTemplateParts)
|
||||
.ChildRules(part =>
|
||||
{
|
||||
part.RuleFor(pathPart => pathPart.Kind)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Library.PathTemplatePartKindNotSupportedForLibraryType);
|
||||
part.RuleFor(pathPart => pathPart.Representation)
|
||||
.NotEmpty()
|
||||
.When(pathPart => !string.Equals(pathPart.Kind, nameof(LibraryPathPartKind.Separator), StringComparison.OrdinalIgnoreCase))
|
||||
.WithError(Errors.Library.PathTemplateLiteralCannotBeEmpty);
|
||||
});
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
|
||||
|
||||
/// <summary>
|
||||
/// Query for getting the path parts available for a media library type.
|
||||
/// </summary>
|
||||
/// <param name="LibraryType">The media library type whose available path parts are retrieved.</param>
|
||||
[DebuggerDisplay("LibraryType: {LibraryType}")]
|
||||
public record GetLibraryPathTemplatePartsQuery(
|
||||
string? LibraryType
|
||||
) : IQuery;
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get the path template catalog available for a media library type.
|
||||
/// </summary>
|
||||
public class GetLibraryPathTemplatePartsQueryHandler : IQueryHandler<GetLibraryPathTemplatePartsQuery, Result<LibraryPathTemplateCatalogResponse>>
|
||||
{
|
||||
private readonly IReadOnlyList<ILibraryPathPartCatalog> _catalogs;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryPathTemplatePartsQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="catalogs">Injected path part catalogs of the supported media library types.</param>
|
||||
public GetLibraryPathTemplatePartsQueryHandler(IEnumerable<ILibraryPathPartCatalog> catalogs)
|
||||
{
|
||||
_catalogs = [.. catalogs];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the query to get the path template catalog available for a media library type.
|
||||
/// </summary>
|
||||
/// <param name="query">The query to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either the path template catalog, or an error message.
|
||||
/// </returns>
|
||||
public Task<Result<LibraryPathTemplateCatalogResponse>> HandleAsync(GetLibraryPathTemplatePartsQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
// the library type travels as a string taken from the route, and is matched against the enum the same way the create and update
|
||||
// library commands do, so that a malformed type is reported as an unknown library type instead of silently returning an empty catalog.
|
||||
if (!Enum.TryParse(query.LibraryType, ignoreCase: true, out LibraryType libraryType))
|
||||
return Task.FromResult<Result<LibraryPathTemplateCatalogResponse>>(DomainErrors.Library.UnknownLibraryType);
|
||||
|
||||
// only the catalog registered for the requested library type applies, so the parts and the default structure offered to the user are
|
||||
// type aware (music libraries get artist and release parts, book libraries get author and title parts, and so on).
|
||||
ILibraryPathPartCatalog? catalog = _catalogs.FirstOrDefault(candidate => candidate.SupportedLibraryType == libraryType);
|
||||
if (catalog is null)
|
||||
// a library type without a catalog has no structure to describe, so an empty catalog is returned, which the client uses to hide the editor.
|
||||
return Task.FromResult(Result<LibraryPathTemplateCatalogResponse>.Success(new LibraryPathTemplateCatalogResponse([], [])));
|
||||
|
||||
// the selectable parts describe what the user can drop into the template, together with the value type and the default on-disk representation of each part.
|
||||
List<LibraryPathPartDefinitionResponse> parts =
|
||||
[
|
||||
.. catalog.GetPartDefinitions().Select(definition => new LibraryPathPartDefinitionResponse(
|
||||
definition.Kind.ToString(),
|
||||
definition.ValueType.ToString(),
|
||||
definition.DefaultRepresentation,
|
||||
definition.IsOptionalByDefault))
|
||||
];
|
||||
// the default template parts describe the ideal structure the application expects, pre-filled in the editor so the user only edits what deviates.
|
||||
List<LibraryPathTemplatePartResponse> defaultTemplateParts =
|
||||
[
|
||||
.. catalog.GetDefaultTemplate().Parts.Select(part => new LibraryPathTemplatePartResponse(part.Kind.ToString(), part.Representation, part.IsOptional))
|
||||
];
|
||||
return Task.FromResult(Result<LibraryPathTemplateCatalogResponse>.Success(new LibraryPathTemplateCatalogResponse(parts, defaultTemplateParts)));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not. Optional.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.</param>
|
||||
/// <param name="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.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record AddLibraryRequest(
|
||||
string? Title,
|
||||
@@ -26,5 +27,6 @@ public record AddLibraryRequest(
|
||||
bool IsLocked,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryPathTemplatePartRequest[]? PathTemplateParts
|
||||
);
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to get the path parts available for a media library type.
|
||||
/// </summary>
|
||||
/// <param name="LibraryType">The media library type whose available path parts are retrieved. Required.</param>
|
||||
[DebuggerDisplay("LibraryType: {LibraryType}")]
|
||||
public record GetLibraryPathTemplatePartsRequest(
|
||||
string? LibraryType
|
||||
);
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents one part of the path template of a media library.
|
||||
/// </summary>
|
||||
/// <param name="Kind">The kind of the path part. Required.</param>
|
||||
/// <param name="Representation">The literal text or the value mask of the path part. Optional for separators, required otherwise.</param>
|
||||
/// <param name="IsOptional">Whether the path part can be absent from the path. Optional.</param>
|
||||
[DebuggerDisplay("Kind: {Kind}; Representation: {Representation}")]
|
||||
public record LibraryPathTemplatePartRequest(
|
||||
string? Kind,
|
||||
string? Representation,
|
||||
bool IsOptional
|
||||
);
|
||||
@@ -19,6 +19,7 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not. Optional.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.</param>
|
||||
/// <param name="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.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record class UpdateLibraryRequest(
|
||||
Guid Id,
|
||||
@@ -31,5 +32,6 @@ public record class UpdateLibraryRequest(
|
||||
bool IsLocked,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryPathTemplatePartRequest[]? PathTemplateParts
|
||||
);
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a path part definition response.
|
||||
/// </summary>
|
||||
/// <param name="Kind">The kind of the path part.</param>
|
||||
/// <param name="ValueType">The value type captured by the path part.</param>
|
||||
/// <param name="DefaultRepresentation">The default representation of the path part, pre-filled when it is added to a template.</param>
|
||||
/// <param name="IsOptionalByDefault">Whether the path part is optional by default.</param>
|
||||
[DebuggerDisplay("Kind: {Kind}; ValueType: {ValueType}")]
|
||||
public record LibraryPathPartDefinitionResponse(
|
||||
string Kind,
|
||||
string ValueType,
|
||||
string DefaultRepresentation,
|
||||
bool IsOptionalByDefault
|
||||
);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a path template catalog response.
|
||||
/// </summary>
|
||||
/// <param name="Parts">The path parts that can be used in the path template of the library type.</param>
|
||||
/// <param name="DefaultTemplateParts">The ordered parts of the default path template of the library type, describing the ideal structure the application expects.</param>
|
||||
[DebuggerDisplay("Parts: {Parts.Count}; DefaultTemplateParts: {DefaultTemplateParts.Count}")]
|
||||
public record LibraryPathTemplateCatalogResponse(
|
||||
List<LibraryPathPartDefinitionResponse> Parts,
|
||||
List<LibraryPathTemplatePartResponse> DefaultTemplateParts
|
||||
);
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a path template part response.
|
||||
/// </summary>
|
||||
/// <param name="Kind">The kind of the path part.</param>
|
||||
/// <param name="Representation">The literal text or the value mask of the path part.</param>
|
||||
/// <param name="IsOptional">Whether the path part can be absent from the path.</param>
|
||||
[DebuggerDisplay("Kind: {Kind}; Representation: {Representation}")]
|
||||
public record LibraryPathTemplatePartResponse(
|
||||
string Kind,
|
||||
string Representation,
|
||||
bool IsOptional
|
||||
);
|
||||
@@ -21,6 +21,7 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether the media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether the media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether the media library should skip the directories whose contents have not changed since the last scan, during the scan.</param>
|
||||
/// <param name="PathTemplateParts">The ordered parts of the template describing the structure of the media library on disk.</param>
|
||||
/// <param name="CreatedOnUtc">The date and time when the library was created.</param>
|
||||
/// <param name="UpdatedOnUtc">The optional date and time when the library was updated.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
@@ -36,6 +37,7 @@ public record LibraryResponse(
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
List<LibraryPathTemplatePartResponse> PathTemplateParts,
|
||||
DateTime CreatedOnUtc,
|
||||
DateTime? UpdatedOnUtc
|
||||
);
|
||||
@@ -66,6 +66,11 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(10);
|
||||
|
||||
builder.Property(library => library.PathTemplateFingerprint)
|
||||
.HasMaxLength(64)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(11);
|
||||
|
||||
// one user with many libraries
|
||||
builder.HasOne(library => library.User)
|
||||
.WithMany(user => user.Libraries)
|
||||
@@ -95,21 +100,48 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
// the path template parts are ordered, so their position is stored explicitly and part of a unique index together with the library
|
||||
builder.OwnsMany(library => library.PathTemplateParts, partBuilder =>
|
||||
{
|
||||
partBuilder.ToTable("LibraryPathTemplateParts");
|
||||
partBuilder.WithOwner()
|
||||
.HasForeignKey("LibraryId");
|
||||
|
||||
partBuilder.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
partBuilder.HasKey("Id");
|
||||
partBuilder.HasIndex("LibraryId", nameof(LibraryPathTemplatePartEntity.Position))
|
||||
.IsUnique();
|
||||
|
||||
partBuilder.Property(part => part.Position)
|
||||
.HasColumnName("Position")
|
||||
.IsRequired();
|
||||
partBuilder.Property(part => part.Kind)
|
||||
.HasConversion<string>()
|
||||
.HasMaxLength(32)
|
||||
.IsRequired();
|
||||
partBuilder.Property(part => part.Representation)
|
||||
.HasMaxLength(512)
|
||||
.IsRequired();
|
||||
partBuilder.Property(part => part.IsOptional)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
// audit
|
||||
builder.Property(library => library.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(11);
|
||||
.HasColumnOrder(12);
|
||||
|
||||
builder.Property(library => library.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(12);
|
||||
.HasColumnOrder(13);
|
||||
|
||||
builder.Property(library => library.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(13);
|
||||
.HasColumnOrder(14);
|
||||
|
||||
builder.Property(library => library.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(14);
|
||||
.HasColumnOrder(15);
|
||||
}
|
||||
}
|
||||
Generated
+3425
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddsLibraryPathTemplate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "UpdatedOnUtc",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 14)
|
||||
.OldAnnotation("Relational:ColumnOrder", 13);
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "UpdatedBy",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 15)
|
||||
.OldAnnotation("Relational:ColumnOrder", 14);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "CreatedOnUtc",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT")
|
||||
.Annotation("Relational:ColumnOrder", 12)
|
||||
.OldAnnotation("Relational:ColumnOrder", 11);
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "CreatedBy",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT")
|
||||
.Annotation("Relational:ColumnOrder", 13)
|
||||
.OldAnnotation("Relational:ColumnOrder", 12);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PathTemplateFingerprint",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
maxLength: 64,
|
||||
nullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 11);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LibraryPathTemplateParts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
Position = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Kind = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
|
||||
Representation = table.Column<string>(type: "TEXT", maxLength: 512, nullable: false),
|
||||
IsOptional = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
LibraryId = table.Column<Guid>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LibraryPathTemplateParts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_LibraryPathTemplateParts_Libraries_LibraryId",
|
||||
column: x => x.LibraryId,
|
||||
principalTable: "Libraries",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LibraryPathTemplateParts_LibraryId_Position",
|
||||
table: "LibraryPathTemplateParts",
|
||||
columns: new[] { "LibraryId", "Position" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "LibraryPathTemplateParts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PathTemplateFingerprint",
|
||||
table: "Libraries");
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "UpdatedOnUtc",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 13)
|
||||
.OldAnnotation("Relational:ColumnOrder", 14);
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "UpdatedBy",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 14)
|
||||
.OldAnnotation("Relational:ColumnOrder", 15);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "CreatedOnUtc",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT")
|
||||
.Annotation("Relational:ColumnOrder", 11)
|
||||
.OldAnnotation("Relational:ColumnOrder", 12);
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "CreatedBy",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT")
|
||||
.Annotation("Relational:ColumnOrder", 12)
|
||||
.OldAnnotation("Relational:ColumnOrder", 13);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -64,6 +64,7 @@ internal sealed class LibraryRepository : ILibraryRepository
|
||||
if (shouldIncludeNavigationProperties)
|
||||
query = query
|
||||
.Include(library => library.ContentLocations)
|
||||
.Include(library => library.PathTemplateParts)
|
||||
.AsSplitQuery();
|
||||
return await query.FirstOrDefaultAsync(library => library.Id == id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
@@ -77,6 +78,7 @@ internal sealed class LibraryRepository : ILibraryRepository
|
||||
{
|
||||
return await _luminaDbContext.Libraries
|
||||
.Include(library => library.ContentLocations)
|
||||
.Include(library => library.PathTemplateParts)
|
||||
.AsSplitQuery()
|
||||
.Where(library => library.IsEnabled)
|
||||
.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
@@ -91,6 +93,7 @@ internal sealed class LibraryRepository : ILibraryRepository
|
||||
{
|
||||
return await _luminaDbContext.Libraries
|
||||
.Include(library => library.ContentLocations)
|
||||
.Include(library => library.PathTemplateParts)
|
||||
.AsSplitQuery()
|
||||
.Where(library => library.IsEnabled && !library.IsLocked)
|
||||
.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
@@ -116,6 +119,7 @@ internal sealed class LibraryRepository : ILibraryRepository
|
||||
if (shouldIncludeNavigationProperties)
|
||||
query = query
|
||||
.Include(library => library.ContentLocations)
|
||||
.Include(library => library.PathTemplateParts)
|
||||
.AsSplitQuery();
|
||||
|
||||
// If no pagination was requested, return all the media libraries.
|
||||
@@ -161,6 +165,7 @@ internal sealed class LibraryRepository : ILibraryRepository
|
||||
{
|
||||
LibraryEntity? foundLibrary = await _luminaDbContext.Libraries
|
||||
.Include(library => library.ContentLocations)
|
||||
.Include(library => library.PathTemplateParts)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(library => library.Id == data.Id, cancellationToken).ConfigureAwait(false);
|
||||
if (foundLibrary is null)
|
||||
@@ -179,6 +184,17 @@ internal sealed class LibraryRepository : ILibraryRepository
|
||||
shouldReplace: (existingContentLocation, incomingContentLocation) => false,
|
||||
createNew: incomingContentLocation => incomingContentLocation);
|
||||
|
||||
// A path template part is matched by its position in the template, and is replaced only when its editable values actually changed.
|
||||
CollectionReconciler.Reconcile(
|
||||
foundLibrary.PathTemplateParts,
|
||||
data.PathTemplateParts,
|
||||
existingPart => existingPart.Position,
|
||||
incomingPart => incomingPart.Position,
|
||||
shouldReplace: (existingPart, incomingPart) => existingPart.Kind != incomingPart.Kind
|
||||
|| existingPart.Representation != incomingPart.Representation
|
||||
|| existingPart.IsOptional != incomingPart.IsOptional,
|
||||
createNew: incomingPart => incomingPart);
|
||||
|
||||
return Result.Updated;
|
||||
}
|
||||
|
||||
@@ -192,6 +208,7 @@ internal sealed class LibraryRepository : ILibraryRepository
|
||||
{
|
||||
LibraryEntity? library = await _luminaDbContext.Libraries
|
||||
.Include(library => library.ContentLocations)
|
||||
.Include(library => library.PathTemplateParts)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(library => library.Id == id, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
namespace Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the kinds of parts that make up a media library path template.
|
||||
/// </summary>
|
||||
public enum LibraryPathPartKind
|
||||
{
|
||||
/// <summary>
|
||||
/// A free text part, used for arbitrary on-disk text and for the literal glue between value parts (e.g. " - ").
|
||||
/// </summary>
|
||||
Literal,
|
||||
|
||||
/// <summary>
|
||||
/// The path separator between two directories of the library structure.
|
||||
/// </summary>
|
||||
Separator,
|
||||
|
||||
/// <summary>
|
||||
/// The name of the artist the release belongs to.
|
||||
/// </summary>
|
||||
Artist,
|
||||
|
||||
/// <summary>
|
||||
/// The type of the release (e.g. Album, Single, Compilation).
|
||||
/// </summary>
|
||||
ReleaseType,
|
||||
|
||||
/// <summary>
|
||||
/// The year the release was published.
|
||||
/// </summary>
|
||||
ReleaseYear,
|
||||
|
||||
/// <summary>
|
||||
/// The title of the release.
|
||||
/// </summary>
|
||||
ReleaseName,
|
||||
|
||||
/// <summary>
|
||||
/// The number of the track on its disc.
|
||||
/// </summary>
|
||||
TrackNumber,
|
||||
|
||||
/// <summary>
|
||||
/// The title of the track.
|
||||
/// </summary>
|
||||
TrackName,
|
||||
|
||||
/// <summary>
|
||||
/// The file name extension of the track, without the leading dot.
|
||||
/// </summary>
|
||||
Extension,
|
||||
|
||||
/// <summary>
|
||||
/// The number of the disc the track belongs to.
|
||||
/// </summary>
|
||||
DiscNumber,
|
||||
|
||||
/// <summary>
|
||||
/// The name of the author of a book.
|
||||
/// </summary>
|
||||
Author,
|
||||
|
||||
/// <summary>
|
||||
/// The title of a book.
|
||||
/// </summary>
|
||||
Title,
|
||||
|
||||
/// <summary>
|
||||
/// The name of the series a book belongs to.
|
||||
/// </summary>
|
||||
Series,
|
||||
|
||||
/// <summary>
|
||||
/// The number of the book within its series.
|
||||
/// </summary>
|
||||
SeriesNumber,
|
||||
|
||||
/// <summary>
|
||||
/// The identifier Calibre assigns to a book on disk.
|
||||
/// </summary>
|
||||
BookId
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the value types captured by the typed parts of a media library path template.
|
||||
/// </summary>
|
||||
public enum LibraryPathValueType
|
||||
{
|
||||
/// <summary>
|
||||
/// The part carries no captured value, like a literal or a path separator.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// The part captures a free text value.
|
||||
/// </summary>
|
||||
Text,
|
||||
|
||||
/// <summary>
|
||||
/// The part captures an integer value.
|
||||
/// </summary>
|
||||
Integer,
|
||||
|
||||
/// <summary>
|
||||
/// The part captures a four digit year.
|
||||
/// </summary>
|
||||
Year,
|
||||
|
||||
/// <summary>
|
||||
/// The part captures a value that is later resolved against an enumeration.
|
||||
/// </summary>
|
||||
Enum
|
||||
}
|
||||
@@ -6,7 +6,10 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Scanners;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -50,6 +53,9 @@ public static class DomainLayerServices
|
||||
services.AddScoped<IMediaLibraryScanningService, MediaLibraryScanningService>();
|
||||
services.AddScoped<IBookLibraryTypeScanner, BookLibraryTypeScanner>();
|
||||
services.AddScoped<IMediaLibraryScannerFactory, MediaLibraryScannerFactory>();
|
||||
services.AddScoped<ILibraryPathPartCatalog, MusicLibraryPathPartCatalog>();
|
||||
services.AddScoped<ILibraryPathPartCatalog, BookLibraryPathPartCatalog>();
|
||||
services.AddScoped<ILibraryPathTemplateService, LibraryPathTemplateService>();
|
||||
|
||||
services.AddSingleton<IFileSystem, FileSystem>();
|
||||
services.AddSingleton<IMediaLibrariesScanProgressTracker, MediaLibrariesScanProgressTracker>();
|
||||
|
||||
@@ -25,5 +25,10 @@ public static partial class Errors
|
||||
public static Error PathsListCannotBeEmpty => Error.Validation(description: nameof(PathsListCannotBeEmpty));
|
||||
public static Error TitleCannotBeEmpty => Error.Validation(description: nameof(TitleCannotBeEmpty));
|
||||
public static Error TitleMustBeMaximum255CharactersLong => Error.Validation(description: nameof(TitleMustBeMaximum255CharactersLong));
|
||||
public static Error PathTemplateLiteralCannotBeEmpty => Error.Validation(description: nameof(PathTemplateLiteralCannotBeEmpty));
|
||||
public static Error PathTemplateValuePartMustContainSinglePlaceholder => Error.Validation(description: nameof(PathTemplateValuePartMustContainSinglePlaceholder));
|
||||
public static Error PathTemplateCannotContainDuplicateValuePart => Error.Validation(description: nameof(PathTemplateCannotContainDuplicateValuePart));
|
||||
public static Error PathTemplatePartKindNotSupportedForLibraryType => Error.Validation(description: nameof(PathTemplatePartKindNotSupportedForLibraryType));
|
||||
public static Error PathTemplateIsNotSupportedForLibraryType => Error.Validation(description: nameof(PathTemplateIsNotSupportedForLibraryType));
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Services.PathTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// Catalog of the path parts available for music libraries, together with the default structure the application expects on disk.
|
||||
/// </summary>
|
||||
public sealed class MusicLibraryPathPartCatalog : ILibraryPathPartCatalog
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the media library type that this catalog supports.
|
||||
/// </summary>
|
||||
public LibraryType SupportedLibraryType => LibraryType.Music;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parts that can be used in the path template of a music library.
|
||||
/// </summary>
|
||||
/// <returns>The available path parts.</returns>
|
||||
public IReadOnlyList<LibraryPathPartDefinition> GetPartDefinitions()
|
||||
{
|
||||
return
|
||||
[
|
||||
new(LibraryPathPartKind.Literal, LibraryPathValueType.None, string.Empty, false),
|
||||
new(LibraryPathPartKind.Separator, LibraryPathValueType.None, string.Empty, false),
|
||||
new(LibraryPathPartKind.Artist, LibraryPathValueType.Text, "{0}", false),
|
||||
new(LibraryPathPartKind.ReleaseType, LibraryPathValueType.Enum, "{0}", false),
|
||||
new(LibraryPathPartKind.ReleaseYear, LibraryPathValueType.Year, "{0}", false),
|
||||
new(LibraryPathPartKind.ReleaseName, LibraryPathValueType.Text, "{0}", false),
|
||||
new(LibraryPathPartKind.TrackNumber, LibraryPathValueType.Integer, "{0:00}", false),
|
||||
new(LibraryPathPartKind.TrackName, LibraryPathValueType.Text, "{0}", false),
|
||||
new(LibraryPathPartKind.Extension, LibraryPathValueType.Text, "{0}", false),
|
||||
new(LibraryPathPartKind.DiscNumber, LibraryPathValueType.Integer, "{0:00}", true)
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default path template of a music library, describing the ideal structure the application expects. The disc segment is
|
||||
/// optional, so that both single disc and multi disc releases are understood.
|
||||
/// </summary>
|
||||
/// <returns>The default path template.</returns>
|
||||
public LibraryPathTemplate GetDefaultTemplate()
|
||||
{
|
||||
return LibraryPathTemplate.Create(
|
||||
[
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Artist, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Separator, null, false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.ReleaseType, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Separator, null, false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.ReleaseYear, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Literal, " - ", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.ReleaseName, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Separator, null, true).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Literal, "Disk ", true).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.DiscNumber, "{0:00}", true).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Separator, null, false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.TrackNumber, "{0:00}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Literal, " - ", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.TrackName, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Literal, ".", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Extension, "{0}", false).Value
|
||||
]);
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the metadata derived from the file system path of a music library item.
|
||||
/// </summary>
|
||||
public class MusicLibraryPathMetadata : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of the artist derived from the path, if applicable.
|
||||
/// </summary>
|
||||
public Optional<string> ArtistName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the release derived from the path, if applicable.
|
||||
/// </summary>
|
||||
public Optional<MusicReleaseType> ReleaseType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the release year derived from the path, if applicable.
|
||||
/// </summary>
|
||||
public Optional<int> ReleaseYear { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the release derived from the path, if applicable.
|
||||
/// </summary>
|
||||
public Optional<string> ReleaseName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of the track derived from the path, if applicable.
|
||||
/// </summary>
|
||||
public Optional<int> TrackNumber { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of the disc the track belongs to, derived from the path, if applicable.
|
||||
/// </summary>
|
||||
public Optional<int> DiscNumber { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the track derived from the path, if applicable.
|
||||
/// </summary>
|
||||
public Optional<string> TrackTitle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MusicLibraryPathMetadata"/> class.
|
||||
/// </summary>
|
||||
/// <param name="artistName">The name of the artist derived from the path, if applicable.</param>
|
||||
/// <param name="releaseType">The type of the release derived from the path, if applicable.</param>
|
||||
/// <param name="releaseYear">The release year derived from the path, if applicable.</param>
|
||||
/// <param name="releaseName">The name of the release derived from the path, if applicable.</param>
|
||||
/// <param name="trackNumber">The number of the track derived from the path, if applicable.</param>
|
||||
/// <param name="discNumber">The number of the disc derived from the path, if applicable.</param>
|
||||
/// <param name="trackTitle">The title of the track derived from the path, if applicable.</param>
|
||||
private MusicLibraryPathMetadata(
|
||||
Optional<string> artistName,
|
||||
Optional<MusicReleaseType> releaseType,
|
||||
Optional<int> releaseYear,
|
||||
Optional<string> releaseName,
|
||||
Optional<int> trackNumber,
|
||||
Optional<int> discNumber,
|
||||
Optional<string> trackTitle)
|
||||
{
|
||||
ArtistName = artistName;
|
||||
ReleaseType = releaseType;
|
||||
ReleaseYear = releaseYear;
|
||||
ReleaseName = releaseName;
|
||||
TrackNumber = trackNumber;
|
||||
DiscNumber = discNumber;
|
||||
TrackTitle = trackTitle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MusicLibraryPathMetadata"/> class from the values captured from a path template.
|
||||
/// </summary>
|
||||
/// <param name="parsedPath">The values captured from the path of the music library item.</param>
|
||||
/// <returns>The metadata derived from the captured values.</returns>
|
||||
public static MusicLibraryPathMetadata FromParsedLibraryPath(ParsedLibraryPath parsedPath)
|
||||
{
|
||||
Optional<MusicReleaseType> releaseType = Optional<MusicReleaseType>.None();
|
||||
Optional<string> releaseTypeValue = parsedPath.GetString(LibraryPathPartKind.ReleaseType);
|
||||
if (releaseTypeValue.HasValue)
|
||||
{
|
||||
// An unrecognized release type folder does not prevent the rest of the path from being derived, it is simply reported as the catch-all type.
|
||||
releaseType = Enum.TryParse(releaseTypeValue.Value, ignoreCase: true, out MusicReleaseType parsedReleaseType)
|
||||
? Optional<MusicReleaseType>.Some(parsedReleaseType)
|
||||
: Optional<MusicReleaseType>.Some(MusicReleaseType.Other);
|
||||
}
|
||||
return new MusicLibraryPathMetadata(
|
||||
parsedPath.GetString(LibraryPathPartKind.Artist),
|
||||
releaseType,
|
||||
parsedPath.GetInt(LibraryPathPartKind.ReleaseYear),
|
||||
parsedPath.GetString(LibraryPathPartKind.ReleaseName),
|
||||
parsedPath.GetInt(LibraryPathPartKind.TrackNumber),
|
||||
parsedPath.GetInt(LibraryPathPartKind.DiscNumber),
|
||||
parsedPath.GetString(LibraryPathPartKind.TrackName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object?> GetEqualityComponents()
|
||||
{
|
||||
yield return ArtistName;
|
||||
yield return ReleaseType;
|
||||
yield return ReleaseYear;
|
||||
yield return ReleaseName;
|
||||
yield return TrackNumber;
|
||||
yield return DiscNumber;
|
||||
yield return TrackTitle;
|
||||
}
|
||||
}
|
||||
+14
@@ -76,6 +76,11 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// </summary>
|
||||
public bool ShouldSkipUnchangedDirectoriesDuringScan { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the template describing the structure of the media library on disk, always populated, with the ideal structure of the library type as its default.
|
||||
/// </summary>
|
||||
public LibraryPathTemplate PathTemplate { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of objects representing the file system paths that make up the media library.
|
||||
/// </summary>
|
||||
@@ -100,6 +105,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="pathTemplate">The template describing the structure of the media library on disk.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
private Library(
|
||||
LibraryId id,
|
||||
@@ -113,6 +119,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryPathTemplate pathTemplate,
|
||||
List<ScanId> scanIds) : base(id)
|
||||
{
|
||||
UserId = userId;
|
||||
@@ -125,6 +132,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb;
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories;
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan;
|
||||
PathTemplate = pathTemplate;
|
||||
_scanIds = scanIds;
|
||||
}
|
||||
|
||||
@@ -141,6 +149,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="pathTemplate">The template describing the structure of the media library on disk.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message.
|
||||
@@ -156,6 +165,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryPathTemplate pathTemplate,
|
||||
List<ScanId> scanIds)
|
||||
{
|
||||
List<FileSystemPathId> tempContentLocations = [];
|
||||
@@ -179,6 +189,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplate,
|
||||
scanIds
|
||||
);
|
||||
}
|
||||
@@ -197,6 +208,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="pathTemplate">The template describing the structure of the media library on disk.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message.
|
||||
@@ -213,6 +225,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryPathTemplate pathTemplate,
|
||||
List<ScanId> scanIds)
|
||||
{
|
||||
List<FileSystemPathId> tempContentLocations = [];
|
||||
@@ -236,6 +249,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplate,
|
||||
scanIds
|
||||
);
|
||||
}
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for one part of a media library path template.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A part is either a <see cref="LibraryPathPartKind.Separator"/>, which renders the platform path separator, a <see cref="LibraryPathPartKind.Literal"/>, which renders its
|
||||
/// <see cref="Representation"/> verbatim, or a typed value part, whose <see cref="Representation"/> is a mask that contains a single <c>{0}</c> placeholder where the captured value goes,
|
||||
/// optionally with a fixed digit width for numeric kinds, like <c>{0:00}</c>.
|
||||
/// </remarks>
|
||||
public class LibraryPathPart : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Matches the value placeholder of a typed part, capturing the optional fixed digit width.
|
||||
/// </summary>
|
||||
private static readonly Regex s_placeholderRegex = new(@"\{0(?::(?<width>0+))?\}", RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of the path part.
|
||||
/// </summary>
|
||||
public LibraryPathPartKind Kind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the representation of the path part, which is the literal text for a literal part, and the value mask for a typed part.
|
||||
/// </summary>
|
||||
public string Representation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the path part can be absent from the path.
|
||||
/// </summary>
|
||||
public bool IsOptional { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryPathPart"/> class.
|
||||
/// </summary>
|
||||
/// <param name="kind">The kind of the path part.</param>
|
||||
/// <param name="representation">The literal text or the value mask of the path part.</param>
|
||||
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
|
||||
private LibraryPathPart(LibraryPathPartKind kind, string representation, bool isOptional)
|
||||
{
|
||||
Kind = kind;
|
||||
Representation = representation;
|
||||
IsOptional = isOptional;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="LibraryPathPart"/> class.
|
||||
/// </summary>
|
||||
/// <param name="kind">The kind of the path part.</param>
|
||||
/// <param name="representation">The literal text or the value mask of the path part.</param>
|
||||
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="LibraryPathPart"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<LibraryPathPart> Create(LibraryPathPartKind kind, string? representation, bool isOptional)
|
||||
{
|
||||
// a separator carries no representation, it always renders the platform path separator.
|
||||
if (kind == LibraryPathPartKind.Separator)
|
||||
return new LibraryPathPart(kind, string.Empty, isOptional);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(representation))
|
||||
return DomainErrors.Library.PathTemplateLiteralCannotBeEmpty;
|
||||
|
||||
// typed parts must carry exactly one value placeholder, so that the position of the captured value is unambiguous.
|
||||
if (kind != LibraryPathPartKind.Literal && s_placeholderRegex.Matches(representation).Count != 1)
|
||||
return DomainErrors.Library.PathTemplateValuePartMustContainSinglePlaceholder;
|
||||
|
||||
return new LibraryPathPart(kind, representation, isOptional);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object?> GetEqualityComponents()
|
||||
{
|
||||
yield return Kind;
|
||||
yield return Representation;
|
||||
yield return IsOptional;
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the ordered sequence of parts that make up the structure of a media library on disk.
|
||||
/// </summary>
|
||||
public class LibraryPathTemplate : ValueObject
|
||||
{
|
||||
private readonly List<LibraryPathPart> _parts;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ordered parts that make up the path template.
|
||||
/// </summary>
|
||||
public IReadOnlyList<LibraryPathPart> Parts => _parts.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the template carries no parts, which means no path derived metadata can be obtained from it.
|
||||
/// </summary>
|
||||
public bool IsEmpty => _parts.Count == 0;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryPathTemplate"/> class.
|
||||
/// </summary>
|
||||
/// <param name="parts">The ordered parts that make up the path template.</param>
|
||||
private LibraryPathTemplate(List<LibraryPathPart> parts)
|
||||
{
|
||||
_parts = parts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="LibraryPathTemplate"/> class.
|
||||
/// </summary>
|
||||
/// <param name="parts">The ordered parts that make up the path template.</param>
|
||||
/// <returns>The created path template.</returns>
|
||||
public static LibraryPathTemplate Create(IEnumerable<LibraryPathPart> parts)
|
||||
{
|
||||
return new LibraryPathTemplate([.. parts]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an empty path template, used by the library types that have no path part catalog yet.
|
||||
/// </summary>
|
||||
/// <returns>The created empty path template.</returns>
|
||||
public static LibraryPathTemplate Empty()
|
||||
{
|
||||
return new LibraryPathTemplate([]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object?> GetEqualityComponents()
|
||||
{
|
||||
return _parts;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the catalog of the path parts available for a given media library type.
|
||||
/// </summary>
|
||||
public interface ILibraryPathPartCatalog
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the media library type that this catalog supports.
|
||||
/// </summary>
|
||||
LibraryType SupportedLibraryType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parts that can be used in the path template of the supported library type.
|
||||
/// </summary>
|
||||
/// <returns>The available path parts.</returns>
|
||||
IReadOnlyList<LibraryPathPartDefinition> GetPartDefinitions();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default path template of the supported library type, describing the ideal structure the application expects.
|
||||
/// </summary>
|
||||
/// <returns>The default path template.</returns>
|
||||
LibraryPathTemplate GetDefaultTemplate();
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service that validates media library path templates and derives metadata from paths using them.
|
||||
/// </summary>
|
||||
public interface ILibraryPathTemplateService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the default path template of the provided <paramref name="libraryType"/>, or an empty template when the type has no path part catalog yet.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The media library type whose default path template is retrieved.</param>
|
||||
/// <returns>The default path template.</returns>
|
||||
LibraryPathTemplate GetDefaultTemplate(LibraryType libraryType);
|
||||
|
||||
/// <summary>
|
||||
/// Validates the provided <paramref name="template"/> against the catalog of the provided <paramref name="libraryType"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The media library type the template belongs to.</param>
|
||||
/// <param name="template">The path template to validate.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Result<Success> Validate(LibraryType libraryType, LibraryPathTemplate template);
|
||||
|
||||
/// <summary>
|
||||
/// Derives the metadata of a media library item from its relative path, using the provided <paramref name="template"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The media library type the template belongs to.</param>
|
||||
/// <param name="template">The path template used to parse the path.</param>
|
||||
/// <param name="relativePath">The path of the media library item, relative to the root of its content location.</param>
|
||||
/// <param name="pathSeparator">The character used to separate path segments on the current platform.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either the derived metadata, or an error. A successful result whose value is <see langword="null"/>
|
||||
/// means the path does not match the template.
|
||||
/// </returns>
|
||||
Result<ParsedLibraryPath?> Parse(LibraryType libraryType, LibraryPathTemplate template, string relativePath, char pathSeparator);
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// Validates media library path templates and derives metadata from paths using them.
|
||||
/// </summary>
|
||||
public sealed class LibraryPathTemplateService : ILibraryPathTemplateService
|
||||
{
|
||||
/// <summary>
|
||||
/// Matches the value placeholder of a typed part, capturing the optional fixed digit width.
|
||||
/// </summary>
|
||||
private static readonly Regex s_placeholderRegex = new(@"\{0(?::(?<width>0+))?\}", RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
|
||||
private readonly IReadOnlyList<ILibraryPathPartCatalog> _catalogs;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryPathTemplateService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="catalogs">The path part catalogs of all the supported media library types.</param>
|
||||
public LibraryPathTemplateService(IEnumerable<ILibraryPathPartCatalog> catalogs)
|
||||
{
|
||||
_catalogs = [.. catalogs];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default path template of the provided <paramref name="libraryType"/>, or an empty template when the type has no path part catalog yet.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The media library type whose default path template is retrieved.</param>
|
||||
/// <returns>The default path template.</returns>
|
||||
public LibraryPathTemplate GetDefaultTemplate(LibraryType libraryType)
|
||||
{
|
||||
return ResolveCatalog(libraryType)?.GetDefaultTemplate() ?? LibraryPathTemplate.Empty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the provided <paramref name="template"/> against the catalog of the provided <paramref name="libraryType"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The media library type the template belongs to.</param>
|
||||
/// <param name="template">The path template to validate.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public Result<Success> Validate(LibraryType libraryType, LibraryPathTemplate template)
|
||||
{
|
||||
if (template.IsEmpty)
|
||||
return Result.Success;
|
||||
|
||||
ILibraryPathPartCatalog? catalog = ResolveCatalog(libraryType);
|
||||
if (catalog is null)
|
||||
return DomainErrors.Library.PathTemplateIsNotSupportedForLibraryType;
|
||||
|
||||
HashSet<LibraryPathPartKind> supportedKinds = [.. catalog.GetPartDefinitions().Select(definition => definition.Kind)];
|
||||
foreach (LibraryPathPart part in template.Parts)
|
||||
if (!supportedKinds.Contains(part.Kind))
|
||||
return DomainErrors.Library.PathTemplatePartKindNotSupportedForLibraryType;
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Derives the metadata of a media library item from its relative path, using the provided <paramref name="template"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The media library type the template belongs to.</param>
|
||||
/// <param name="template">The path template used to parse the path.</param>
|
||||
/// <param name="relativePath">The path of the media library item, relative to the root of its content location.</param>
|
||||
/// <param name="pathSeparator">The character used to separate path segments on the current platform.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either the derived metadata, or an error. A successful result whose value is <see langword="null"/>
|
||||
/// means the path does not match the template.
|
||||
/// </returns>
|
||||
public Result<ParsedLibraryPath?> Parse(LibraryType libraryType, LibraryPathTemplate template, string relativePath, char pathSeparator)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(relativePath) || template.IsEmpty)
|
||||
return Result<ParsedLibraryPath?>.Success(null);
|
||||
|
||||
Result<Success> validationResult = Validate(libraryType, template);
|
||||
if (validationResult.IsFailure)
|
||||
return validationResult.Errors;
|
||||
|
||||
ILibraryPathPartCatalog catalog = ResolveCatalog(libraryType)!;
|
||||
Dictionary<LibraryPathPartKind, LibraryPathPartDefinition> definitions = catalog.GetPartDefinitions()
|
||||
.ToDictionary(definition => definition.Kind);
|
||||
Regex pattern = BuildPattern(template, definitions, pathSeparator);
|
||||
Match match = pattern.Match(relativePath);
|
||||
if (!match.Success)
|
||||
return Result<ParsedLibraryPath?>.Success(null);
|
||||
|
||||
Dictionary<LibraryPathPartKind, string> values = [];
|
||||
foreach (LibraryPathPart part in template.Parts)
|
||||
{
|
||||
if (part.Kind == LibraryPathPartKind.Literal || part.Kind == LibraryPathPartKind.Separator)
|
||||
continue;
|
||||
// a kind can legitimately appear more than once, like the title and the author appearing both in the directory and in the file name,
|
||||
// so the first non-empty capture is kept.
|
||||
if (values.ContainsKey(part.Kind))
|
||||
continue;
|
||||
Group group = match.Groups[part.Kind.ToString()];
|
||||
if (!group.Success)
|
||||
continue;
|
||||
string? value = group.Captures.Cast<Capture>().Select(capture => capture.Value).FirstOrDefault(captured => !string.IsNullOrWhiteSpace(captured));
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
values[part.Kind] = value;
|
||||
}
|
||||
return Result<ParsedLibraryPath?>.Success(ParsedLibraryPath.Create(values));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the catalog of the provided <paramref name="libraryType"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The media library type whose catalog is resolved.</param>
|
||||
/// <returns>The resolved catalog, or <see langword="null"/> when the type has no catalog.</returns>
|
||||
private ILibraryPathPartCatalog? ResolveCatalog(LibraryType libraryType)
|
||||
{
|
||||
return _catalogs.FirstOrDefault(catalog => catalog.SupportedLibraryType == libraryType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the regular expression that matches the provided <paramref name="template"/>.
|
||||
/// </summary>
|
||||
/// <param name="template">The path template to compile.</param>
|
||||
/// <param name="definitions">The available part definitions of the template's library type.</param>
|
||||
/// <param name="pathSeparator">The character used to separate path segments on the current platform.</param>
|
||||
/// <returns>The compiled regular expression.</returns>
|
||||
private static Regex BuildPattern(LibraryPathTemplate template, IReadOnlyDictionary<LibraryPathPartKind, LibraryPathPartDefinition> definitions, char pathSeparator)
|
||||
{
|
||||
StringBuilder patternBuilder = new("^");
|
||||
int index = 0;
|
||||
while (index < template.Parts.Count)
|
||||
{
|
||||
int runStart = index;
|
||||
bool isOptionalRun = template.Parts[index].IsOptional;
|
||||
do
|
||||
{
|
||||
index++;
|
||||
}
|
||||
while (index < template.Parts.Count && template.Parts[index].IsOptional == isOptionalRun);
|
||||
|
||||
StringBuilder runBuilder = new();
|
||||
for (int runIndex = runStart; runIndex < index; runIndex++)
|
||||
runBuilder.Append(BuildFragment(template.Parts[runIndex], definitions, pathSeparator));
|
||||
|
||||
if (isOptionalRun)
|
||||
patternBuilder.Append("(?:").Append(runBuilder).Append(")?");
|
||||
else
|
||||
patternBuilder.Append(runBuilder);
|
||||
}
|
||||
patternBuilder.Append('$');
|
||||
return new Regex(patternBuilder.ToString(), RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the regular expression fragment of a single path part.
|
||||
/// </summary>
|
||||
/// <param name="part">The path part to compile.</param>
|
||||
/// <param name="definitions">The available part definitions of the template's library type.</param>
|
||||
/// <param name="pathSeparator">The character used to separate path segments on the current platform.</param>
|
||||
/// <returns>The compiled regular expression fragment.</returns>
|
||||
private static string BuildFragment(LibraryPathPart part, IReadOnlyDictionary<LibraryPathPartKind, LibraryPathPartDefinition> definitions, char pathSeparator)
|
||||
{
|
||||
if (part.Kind == LibraryPathPartKind.Separator)
|
||||
return Regex.Escape(pathSeparator.ToString());
|
||||
if (part.Kind == LibraryPathPartKind.Literal)
|
||||
return Regex.Escape(part.Representation);
|
||||
|
||||
LibraryPathPartDefinition definition = definitions[part.Kind];
|
||||
Match placeholder = s_placeholderRegex.Match(part.Representation);
|
||||
string prefix = part.Representation[..placeholder.Index];
|
||||
string suffix = part.Representation[(placeholder.Index + placeholder.Length)..];
|
||||
Group width = placeholder.Groups["width"];
|
||||
// a fixed width narrows the capture to an exact number of digits, otherwise the base pattern of the value type is used.
|
||||
string valuePattern = width.Success ? $@"\d{{{width.Value.Length}}}" : GetValuePattern(definition.ValueType);
|
||||
return Regex.Escape(prefix) + $"(?<{part.Kind}>{valuePattern})" + Regex.Escape(suffix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base regular expression pattern of the provided <paramref name="valueType"/>.
|
||||
/// </summary>
|
||||
/// <param name="valueType">The value type whose base pattern is retrieved.</param>
|
||||
/// <returns>The base regular expression pattern.</returns>
|
||||
private static string GetValuePattern(LibraryPathValueType valueType)
|
||||
{
|
||||
return valueType switch
|
||||
{
|
||||
LibraryPathValueType.Year => @"\d{4}",
|
||||
LibraryPathValueType.Integer => @"\d+",
|
||||
_ => @"[^/\\]+"
|
||||
};
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object that describes one available part of a media library path template, for a given library type.
|
||||
/// </summary>
|
||||
public sealed class LibraryPathPartDefinition : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the kind of the described part.
|
||||
/// </summary>
|
||||
public LibraryPathPartKind Kind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value type captured by the described part.
|
||||
/// </summary>
|
||||
public LibraryPathValueType ValueType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default representation of the described part, pre-filled for the user when the part is added to a template.
|
||||
/// </summary>
|
||||
public string DefaultRepresentation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the described part is optional by default.
|
||||
/// </summary>
|
||||
public bool IsOptionalByDefault { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryPathPartDefinition"/> class.
|
||||
/// </summary>
|
||||
/// <param name="kind">The kind of the described part.</param>
|
||||
/// <param name="valueType">The value type captured by the described part.</param>
|
||||
/// <param name="defaultRepresentation">The default representation of the described part.</param>
|
||||
/// <param name="isOptionalByDefault">Whether the described part is optional by default.</param>
|
||||
public LibraryPathPartDefinition(LibraryPathPartKind kind, LibraryPathValueType valueType, string defaultRepresentation, bool isOptionalByDefault)
|
||||
{
|
||||
Kind = kind;
|
||||
ValueType = valueType;
|
||||
DefaultRepresentation = defaultRepresentation;
|
||||
IsOptionalByDefault = isOptionalByDefault;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object?> GetEqualityComponents()
|
||||
{
|
||||
yield return Kind;
|
||||
yield return ValueType;
|
||||
yield return DefaultRepresentation;
|
||||
yield return IsOptionalByDefault;
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the values captured from the relative path of a media library item, keyed by the semantic kind of the path part that produced them.
|
||||
/// </summary>
|
||||
public class ParsedLibraryPath : ValueObject
|
||||
{
|
||||
private readonly IReadOnlyDictionary<LibraryPathPartKind, string> _values;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the captured values, keyed by their part kind.
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<LibraryPathPartKind, string> Values => _values;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ParsedLibraryPath"/> class.
|
||||
/// </summary>
|
||||
/// <param name="values">The captured values, keyed by their part kind.</param>
|
||||
private ParsedLibraryPath(IReadOnlyDictionary<LibraryPathPartKind, string> values)
|
||||
{
|
||||
_values = values;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ParsedLibraryPath"/> class.
|
||||
/// </summary>
|
||||
/// <param name="values">The captured values, keyed by their part kind.</param>
|
||||
/// <returns>The created parsed path.</returns>
|
||||
public static ParsedLibraryPath Create(IReadOnlyDictionary<LibraryPathPartKind, string> values)
|
||||
{
|
||||
return new ParsedLibraryPath(values);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the captured value of the part of the provided <paramref name="kind"/>.
|
||||
/// </summary>
|
||||
/// <param name="kind">The kind of the part whose value is retrieved.</param>
|
||||
/// <returns>An <see cref="Optional{TValue}"/> containing the captured value, or no value when the part was not captured.</returns>
|
||||
public Optional<string> GetString(LibraryPathPartKind kind)
|
||||
{
|
||||
return _values.TryGetValue(kind, out string? value) && !string.IsNullOrWhiteSpace(value)
|
||||
? Optional<string>.Some(value.Trim())
|
||||
: Optional<string>.None();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the captured integer value of the part of the provided <paramref name="kind"/>.
|
||||
/// </summary>
|
||||
/// <param name="kind">The kind of the part whose value is retrieved.</param>
|
||||
/// <returns>An <see cref="Optional{TValue}"/> containing the captured integer, or no value when the part was not captured or is not an integer.</returns>
|
||||
public Optional<int> GetInt(LibraryPathPartKind kind)
|
||||
{
|
||||
return _values.TryGetValue(kind, out string? value) && int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int parsed)
|
||||
? Optional<int>.Some(parsed)
|
||||
: Optional<int>.None();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the captured values as a dictionary, for callers that need to iterate over all of them.
|
||||
/// </summary>
|
||||
/// <returns>The captured values keyed by part kind.</returns>
|
||||
public IReadOnlyDictionary<LibraryPathPartKind, string> ToDictionary()
|
||||
{
|
||||
return _values.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object?> GetEqualityComponents()
|
||||
{
|
||||
// the captured values are stored in a dictionary, so they are ordered by their kind to keep equality independent of insertion order.
|
||||
foreach (KeyValuePair<LibraryPathPartKind, string> capturedValue in _values.OrderBy(capturedValue => capturedValue.Key))
|
||||
{
|
||||
yield return capturedValue.Key;
|
||||
yield return capturedValue.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.PathTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// Catalog of the path parts available for book libraries, together with the default structure the application expects on disk.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default structure mirrors the Calibre library layout, where each book lives in an author directory and a book directory named after
|
||||
/// the title and the Calibre identifier, holding the book file named after the title and the author.
|
||||
/// </remarks>
|
||||
public sealed class BookLibraryPathPartCatalog : ILibraryPathPartCatalog
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the media library type that this catalog supports.
|
||||
/// </summary>
|
||||
public LibraryType SupportedLibraryType => LibraryType.Book;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parts that can be used in the path template of a book library.
|
||||
/// </summary>
|
||||
/// <returns>The available path parts.</returns>
|
||||
public IReadOnlyList<LibraryPathPartDefinition> GetPartDefinitions()
|
||||
{
|
||||
return
|
||||
[
|
||||
new(LibraryPathPartKind.Literal, LibraryPathValueType.None, string.Empty, false),
|
||||
new(LibraryPathPartKind.Separator, LibraryPathValueType.None, string.Empty, false),
|
||||
new(LibraryPathPartKind.Author, LibraryPathValueType.Text, "{0}", false),
|
||||
new(LibraryPathPartKind.Title, LibraryPathValueType.Text, "{0}", false),
|
||||
new(LibraryPathPartKind.Series, LibraryPathValueType.Text, "{0}", true),
|
||||
new(LibraryPathPartKind.SeriesNumber, LibraryPathValueType.Integer, "{0}", true),
|
||||
new(LibraryPathPartKind.BookId, LibraryPathValueType.Integer, "{0}", false),
|
||||
new(LibraryPathPartKind.Extension, LibraryPathValueType.Text, "{0}", false)
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default path template of a book library, describing the Calibre structure the application expects.
|
||||
/// </summary>
|
||||
/// <returns>The default path template.</returns>
|
||||
public LibraryPathTemplate GetDefaultTemplate()
|
||||
{
|
||||
return LibraryPathTemplate.Create(
|
||||
[
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Author, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Separator, null, false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Title, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Literal, " (", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.BookId, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Literal, ")", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Separator, null, false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Title, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Literal, " - ", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Author, "{0}", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Literal, ".", false).Value,
|
||||
LibraryPathPart.Create(LibraryPathPartKind.Extension, "{0}", false).Value
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
));
|
||||
|
||||
@@ -67,4 +67,9 @@ public class LibraryDto
|
||||
/// which does not change when the contents of an existing file are edited, and such edits could be missed while this setting is enabled.
|
||||
/// </summary>
|
||||
public bool ShouldSkipUnchangedDirectoriesDuringScan { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ordered parts of the template describing the structure of the media library on disk.
|
||||
/// </summary>
|
||||
public List<LibraryPathTemplatePartDto> PathTemplateParts { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a path part available for a media library type.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Kind: {Kind}")]
|
||||
public class LibraryPathPartDefinitionDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of the path part.
|
||||
/// </summary>
|
||||
public string Kind { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value type captured by the path part.
|
||||
/// </summary>
|
||||
public string ValueType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default representation of the path part.
|
||||
/// </summary>
|
||||
public string DefaultRepresentation { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the path part is optional by default.
|
||||
/// </summary>
|
||||
public bool IsOptionalByDefault { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the path template catalog of a media library type.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Parts: {Parts.Count}; DefaultTemplateParts: {DefaultTemplateParts.Count}")]
|
||||
public class LibraryPathTemplateCatalogDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the path parts that can be used in the path template of the library type.
|
||||
/// </summary>
|
||||
public List<LibraryPathPartDefinitionDto> Parts { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ordered parts of the default path template of the library type.
|
||||
/// </summary>
|
||||
public List<LibraryPathTemplatePartDto> DefaultTemplateParts { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for one part of the path template of a media library.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Kind: {Kind}; Representation: {Representation}")]
|
||||
public class LibraryPathTemplatePartDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of the path part.
|
||||
/// </summary>
|
||||
public string Kind { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the literal text or the value mask of the path part.
|
||||
/// </summary>
|
||||
public string Representation { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the path part can be absent from the path.
|
||||
/// </summary>
|
||||
public bool IsOptional { get; set; }
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the request for retrieving the path parts available for a media library type.
|
||||
/// </summary>
|
||||
/// <param name="LibraryType">The media library type whose available path parts are retrieved. Required.</param>
|
||||
[DebuggerDisplay("LibraryType: {LibraryType}")]
|
||||
public record GetLibraryPathTemplatePartsRequest(
|
||||
string LibraryType
|
||||
);
|
||||
@@ -21,6 +21,7 @@ public static partial class ApiRoutes
|
||||
public const string GET_RUNNING_LIBRARIES_SCAN = "libraries/scans/running";
|
||||
public const string CANCEL_LIBRARIES_SCAN = "libraries/scans/cancel";
|
||||
public const string CANCEL_LIBRARY_SCAN = "libraries/{libraryId}/scans/{scanId}/cancel";
|
||||
public const string GET_LIBRARY_PATH_TEMPLATE_PARTS = "libraries/path-template-parts/{libraryType}";
|
||||
public const string GET_LIBRARY_METADATA_PROVIDERS = "libraries/{libraryId}/metadata-providers";
|
||||
public const string SET_LIBRARY_METADATA_PROVIDER_ENABLED = "libraries/{libraryId}/metadata-providers/{pluginId}/enabled";
|
||||
public const string REORDER_LIBRARY_METADATA_PROVIDERS = "libraries/{libraryId}/metadata-providers/reorder";
|
||||
|
||||
@@ -22,6 +22,7 @@ public static partial class WebRoutes
|
||||
public const string SCAN_LIBRARY = "{culture}/libraries/manage/api-scan-library/{id}";
|
||||
public const string CANCEL_LIBRARIES_SCAN = "{culture}/libraries/manage/api-cancel-libraries-scan";
|
||||
public const string CANCEL_LIBRARY_SCAN = "{culture}/libraries/manage/{libraryId}/api-cancel-library-scan/{scanId}";
|
||||
public const string GET_LIBRARY_PATH_TEMPLATE_PARTS = "{culture}/libraries/manage/api-get-path-template-parts/{libraryType}";
|
||||
public const string GET_METADATA_PROVIDERS = "{culture}/libraries/manage/api-get-metadata-providers/{libraryId}";
|
||||
public const string SET_METADATA_PROVIDER_ENABLED = "{culture}/libraries/manage/api-set-metadata-provider-enabled";
|
||||
public const string REORDER_METADATA_PROVIDERS = "{culture}/libraries/manage/api-reorder-metadata-providers";
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetLibraryPathTemplateParts;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-get-path-template-parts/{libraryType}</c> route.
|
||||
/// </summary>
|
||||
public class GetLibraryPathTemplatePartsEndpoint : BaseEndpoint<GetLibraryPathTemplatePartsRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryPathTemplatePartsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetLibraryPathTemplatePartsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.LibraryManagement.GET_LIBRARY_PATH_TEMPLATE_PARTS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves 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)
|
||||
{
|
||||
LibraryPathTemplateCatalogDto response = await _apiHttpClient.GetAsync<LibraryPathTemplateCatalogDto>(ApiRoutes.Libraries.GET_LIBRARY_PATH_TEMPLATE_PARTS.Replace("{libraryType}", request.LibraryType), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>قارئات الكتب المستخدمة لقراءة كتب هذه المكتبة. القارئة المعطّلة تتيح للمستخدم معرفة أن هناك إضافة قارئ لهذا التنسيق، لكنها معطّلة.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>قالب المسار</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>يصف كيفية تنظيم مسارات هذه المكتبة على القرص، حتى يفهم التطبيق معنى كل مجلد واسم ملف. اسحب العناصر المتاحة إلى المسار بالترتيب الذي تظهر به على القرص. يمكن تعديل كل عنصر ليطابق طريقة كتابته في مكتبتك، وتضع علامة الاختيار عليه علامة اختياري عندما لا يكون موجودًا دائمًا. تعرض المعاينة مسارًا كمثال.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>معاينة</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>نص</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>فاصل</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>الفنان</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>نوع الإصدار</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>سنة الإصدار</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>اسم الإصدار</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>رقم المقطع</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>اسم المقطع</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>الامتداد</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>رقم القرص</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>وضع علامة اختياري</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>نص</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>أرقام</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>المؤلف</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>العنوان</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>السلسلة</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>رقم السلسلة</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>معرف الكتاب</value>
|
||||
</data>
|
||||
</root>
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>Die Buchleser, die zum Lesen der Bücher dieser Bibliothek verwendet werden. Ein deaktivierter Buchleser informiert den Benutzer darüber, dass ein Leser-Plugin für das Format existiert, es aber deaktiviert ist.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>Pfadvorlage</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>Beschreibt, wie die Pfade dieser Bibliothek auf dem Datenträger aufgebaut sind, damit die Anwendung versteht, was jeder Ordner- und Dateiname bedeutet. Ziehe die verfügbaren Bausteine in der Reihenfolge, in der sie auf dem Datenträger vorkommen, in den Pfad. Jeder Baustein kann so bearbeitet werden, wie er in deiner Bibliothek geschrieben wird, und sein Kontrollkästchen markiert ihn als optional, wenn er nicht immer vorhanden ist. Die Vorschau zeigt einen Beispielpfad.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>Vorschau</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>Text</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>Trennzeichen</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>Interpret</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>Veröffentlichungstyp</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>Erscheinungsjahr</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>Veröffentlichungsname</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>Titelnummer</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>Titelname</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>Erweiterung</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>Disknummer</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>Als optional markieren</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>Text</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>Ziffern</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>Autor</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>Titel</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>Reihe</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>Reihennummer</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>Buch-ID</value>
|
||||
</data>
|
||||
</root>
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>The book readers used to read the books of this library. A disabled book reader lets the user know that a reader plugin exists for the format, but it is disabled.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>Path template</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>Describes how the paths of this library are structured on disk, so the application understands what each folder and file name means. Drag the available pieces into the path, in the order they appear on disk. Each piece can be edited to match how it is written in your library, and its checkmark marks it as optional when it is not always present. The preview shows an example path.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>Preview</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>Text</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>Separator</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>Artist</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>Release type</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>Release year</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>Release name</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>Track number</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>Track name</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>Extension</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>Disc number</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>Mark as optional</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>text</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>digits</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>Author</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>Title</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>Series</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>Series number</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>Book id</value>
|
||||
</data>
|
||||
</root>
|
||||
+65
-2
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -346,9 +346,72 @@
|
||||
<value>Lectores de libros</value>
|
||||
</data>
|
||||
<data name="SupportedExtensions" xml:space="preserve">
|
||||
<value>Extensiones compatibles</value>
|
||||
<value>Extensiónes compatibles</value>
|
||||
</data>
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>Los lectores de libros utilizados para leer los libros de esta biblioteca. Un lector deshabilitado le indica al usuario que existe un complemento de lectura para el formato, pero que está deshabilitado.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>Plantilla de ruta</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>Describe cómo están estructuradas en disco las rutas de esta biblioteca, para que la aplicación entienda qué significa cada carpeta y cada nombre de archivo. Arrastra las piezas disponibles a la ruta en el orden en que aparecen en disco. Cada pieza se puede editar para que coincida con cómo está escrita en tu biblioteca, y su casilla la marca como opcional cuando no siempre está presente. La vista previa muestra una ruta de ejemplo.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>Vista previa</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>Texto</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>Separador</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>Artista</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>Tipo de lanzamiento</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>Año de lanzamiento</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>Nombre del lanzamiento</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>Número de pista</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>Nombre de la pista</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>Extensión</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>Número de disco</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>Marcar como opcional</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>texto</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>dígitos</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>Autor</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>Título</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>Serie</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>Número de serie</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>Id del libro</value>
|
||||
</data>
|
||||
</root>
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>Les lecteurs de livres utilisés pour lire les livres de cette bibliothèque. Un lecteur désactivé indique à l'utilisateur qu'un plugin de lecture existe pour le format, mais qu'il est désactivé.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>Modèle de chemin</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>Décrit la structure des chemins de cette bibliothèque sur le disque, afin que l'application comprenne ce que signifie chaque dossier et chaque nom de fichier. Faites glisser les éléments disponibles dans le chemin, dans l'ordre où ils apparaissent sur le disque. Chaque élément peut être modifié pour correspondre à la façon dont il est écrit dans votre bibliothèque, et sa case le marque comme facultatif lorsqu'il n'est pas toujours présent. L'aperçu montre un chemin d'exemple.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>Aperçu</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>Texte</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>Séparateur</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>Artiste</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>Type de sortie</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>Année de sortie</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>Nom de la sortie</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>Numéro de piste</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>Nom de la piste</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>Extension</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>Numéro de disque</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>Marquer comme facultatif</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>texte</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>chiffres</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>Auteur</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>Titre</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>Série</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>Numéro de série</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>Id du livre</value>
|
||||
</data>
|
||||
</root>
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>I lettori di libri utilizzati per leggere i libri di questa libreria. Un lettore disabilitato informa l'utente che esiste un plugin di lettura per il formato, ma che è disabilitato.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>Modello di percorso</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>Descrive come sono strutturati su disco i percorsi di questa libreria, così che l'applicazione capisca cosa significa ogni cartella e ogni nome di file. Trascina gli elementi disponibili nel percorso, nell'ordine in cui appaiono su disco. Ogni elemento può essere modificato per corrispondere a come è scritto nella tua libreria, e la sua casella lo contrassegna come opzionale quando non è sempre presente. L'anteprima mostra un percorso di esempio.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>Anteprima</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>Testo</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>Separatore</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>Artista</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>Tipo di pubblicazione</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>Anno di pubblicazione</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>Nome della pubblicazione</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>Numero di traccia</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>Nome della traccia</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>Estensione</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>Numero di disco</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>Contrassegna come opzionale</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>testo</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>cifre</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>Autore</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>Titolo</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>Serie</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>Numero di serie</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>Id del libro</value>
|
||||
</data>
|
||||
</root>
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>このライブラリの書籍を読むために使用されるリーダーです。無効なリーダーは、その形式のリーダープラグインが存在するが無効になっていることをユーザーに知らせます。</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>パステンプレート</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>このライブラリのディスク上のパスの構造を記述し、各フォルダー名とファイル名が何を意味するかをアプリが理解できるようにします。利用可能な部品を、ディスク上の並び順でパスにドラッグしてください。各部品はライブラリでの表記に合わせて編集でき、チェックボックスをオンにすると、常に存在しない場合に任意としてマークされます。プレビューにはパスの例が表示されます。</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>プレビュー</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>テキスト</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>区切り</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>アーティスト</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>リリース種別</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>リリース年</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>リリース名</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>トラック番号</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>トラック名</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>拡張子</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>ディスク番号</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>任意としてマーク</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>テキスト</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>桁数</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>著者</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>タイトル</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>シリーズ</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>シリーズ番号</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>書籍ID</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>The book readers used to read the books of this library. A disabled book reader lets the user know that a reader plugin exists for the format, but it is disabled.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>Path template</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>Describes how the paths of this library are structured on disk, so the application understands what each folder and file name means. Drag the available pieces into the path, in the order they appear on disk. Each piece can be edited to match how it is written in your library, and its checkmark marks it as optional when it is not always present. The preview shows an example path.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>Preview</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>Text</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>Separator</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>Artist</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>Release type</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>Release year</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>Release name</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>Track number</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>Track name</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>Extension</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>Disc number</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>Mark as optional</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>text</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>digits</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>Author</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>Title</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>Series</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>Series number</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>Book id</value>
|
||||
</data>
|
||||
</root>
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>Cititorii de cărți folosiți pentru a citi cărțile acestei biblioteci. Un cititor dezactivat îi permite utilizatorului să știe că există un plugin de citire pentru format, dar este dezactivat.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>Șablon de cale</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>Descrie modul în care sunt structurate pe disc căile acestei biblioteci, astfel încât aplicația să înțeleagă ce înseamnă fiecare folder și fiecare nume de fișier. Trage piesele disponibile în cale, în ordinea în care apar pe disc. Fiecare piesă poate fi editată pentru a corespunde modului în care este scrisă în biblioteca ta, iar caseta ei o marchează ca opțională atunci când nu este mereu prezentă. Previzualizarea arată o cale exemplu.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>Previzualizare</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>Text</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>Separator</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>Artist</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>Tip de lansare</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>Anul lansării</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>Numele lansării</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>Numărul piesei</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>Numele piesei</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>Extensie</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>Numărul discului</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>Marchează ca opțional</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>text</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>cifre</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>Autor</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>Titlu</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>Serie</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>Numărul seriei</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>Id-ul cărții</value>
|
||||
</data>
|
||||
</root>
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>Читачі книг, які використовуються для читання книг цієї бібліотеки. Вимкнений читач повідомляє користувача про те, що для цього формату існує плагін для читання, але він вимкнений.</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>Шаблон шляху</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>Описує структуру шляхів цієї бібліотеки на диску, щоб застосунок розумів, що означає кожна тека та назва файлу. Перетягніть доступні частини у шлях у тому порядку, в якому вони з'являються на диску. Кожну частину можна змінити відповідно до того, як вона записана у вашій бібліотеці, а її прапорець позначає її як необов'язкову, коли вона присутня не завжди. Попередній перегляд показує приклад шляху.</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>Попередній перегляд</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>Текст</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>Розділювач</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>Виконавець</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>Тип випуску</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>Рік випуску</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>Назва випуску</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>Номер треку</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>Назва треку</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>Розширення</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>Номер диска</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>Позначити як необов'язкове</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>текст</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>цифри</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>Автор</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>Назва</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>Серія</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>Номер серії</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>Ідентифікатор книги</value>
|
||||
</data>
|
||||
</root>
|
||||
+64
-1
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -351,4 +351,67 @@
|
||||
<data name="DescriptionBookReaders" xml:space="preserve">
|
||||
<value>用于阅读此库书籍的阅读器。禁用的阅读器会让用户知道该格式存在阅读器插件,但该插件已被禁用。</value>
|
||||
</data>
|
||||
<data name="PathTemplate" xml:space="preserve">
|
||||
<value>路径模板</value>
|
||||
</data>
|
||||
<data name="DescriptionPathTemplate" xml:space="preserve">
|
||||
<value>描述此媒体库在磁盘上的路径结构,使应用程序能够理解每个文件夹和文件名所代表的含义。按它们在磁盘上出现的顺序,将可用的部件拖入路径。每个部件都可以编辑,以匹配它在你的媒体库中的写法;勾选其复选框可在它并非总是存在时将其标记为可选。预览会显示一个示例路径。</value>
|
||||
</data>
|
||||
<data name="PathTemplatePreview" xml:space="preserve">
|
||||
<value>预览</value>
|
||||
</data>
|
||||
<data name="PathPartLiteral" xml:space="preserve">
|
||||
<value>文本</value>
|
||||
</data>
|
||||
<data name="PathPartSeparator" xml:space="preserve">
|
||||
<value>分隔符</value>
|
||||
</data>
|
||||
<data name="PathPartArtist" xml:space="preserve">
|
||||
<value>艺术家</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseType" xml:space="preserve">
|
||||
<value>发行类型</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseYear" xml:space="preserve">
|
||||
<value>发行年份</value>
|
||||
</data>
|
||||
<data name="PathPartReleaseName" xml:space="preserve">
|
||||
<value>发行名称</value>
|
||||
</data>
|
||||
<data name="PathPartTrackNumber" xml:space="preserve">
|
||||
<value>曲目编号</value>
|
||||
</data>
|
||||
<data name="PathPartTrackName" xml:space="preserve">
|
||||
<value>曲目名称</value>
|
||||
</data>
|
||||
<data name="PathPartExtension" xml:space="preserve">
|
||||
<value>扩展名</value>
|
||||
</data>
|
||||
<data name="PathPartDiscNumber" xml:space="preserve">
|
||||
<value>光盘编号</value>
|
||||
</data>
|
||||
<data name="PathPartOptional" xml:space="preserve">
|
||||
<value>标记为可选</value>
|
||||
</data>
|
||||
<data name="PathPartLiteralPlaceholder" xml:space="preserve">
|
||||
<value>文本</value>
|
||||
</data>
|
||||
<data name="PathPartDigits" xml:space="preserve">
|
||||
<value>位数</value>
|
||||
</data>
|
||||
<data name="PathPartAuthor" xml:space="preserve">
|
||||
<value>作者</value>
|
||||
</data>
|
||||
<data name="PathPartTitle" xml:space="preserve">
|
||||
<value>标题</value>
|
||||
</data>
|
||||
<data name="PathPartSeries" xml:space="preserve">
|
||||
<value>系列</value>
|
||||
</data>
|
||||
<data name="PathPartSeriesNumber" xml:space="preserve">
|
||||
<value>系列编号</value>
|
||||
</data>
|
||||
<data name="PathPartBookId" xml:space="preserve">
|
||||
<value>书籍编号</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
@{
|
||||
var id = Context.Request.RouteValues["id"] as string;
|
||||
// generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler
|
||||
// Generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler.
|
||||
var scriptId = ScriptIdentifierHelper.GenerateScriptId();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
@await Component.InvokeAsync("FileSystemBrowser")
|
||||
|
||||
<div style="display: grid; grid-template-rows: auto 1fr;"><!--container with two rows, one fixed, one filling remaining space-->
|
||||
<div style="min-height: 1rem;"></div><!--the first row is a dummy row for "margin", because setting a margin on the next row would offset the parent's position-->
|
||||
<div style="display: grid; grid-template-rows: auto 1fr;"><!-- Container with two rows, one fixed, one filling remaining space. -->
|
||||
<div style="min-height: 1rem;"></div><!-- The first row is a dummy row for "margin", because setting a margin on the next row would offset the parent's position. -->
|
||||
<div class="enlightenment-panel shadow-effect mx-auto panel w-50 mb-10" style="min-width: 320px;">
|
||||
<div class="shine-effect"></div>
|
||||
<form method="post" id="add-media-library-form" class="inline">
|
||||
@@ -34,7 +34,7 @@
|
||||
</div>
|
||||
<div class="form-container">
|
||||
<h3 class="text-light-two">@_localizer["GeneralInformation"]</h3>
|
||||
<!-- Title -->
|
||||
<!-- Title. -->
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="Title">@_localizer["Title"]</label>
|
||||
@@ -45,7 +45,7 @@
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionTitle"]</small>
|
||||
</div>
|
||||
<!-- Library Type -->
|
||||
<!-- Library Type. -->
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="LibraryType">@_localizer["LibraryType"]</label>
|
||||
@@ -77,25 +77,25 @@
|
||||
<div class="enlightenment-option" data-value="Movie">@_localizer["Movie"]</div>
|
||||
<div class="enlightenment-option" data-value="FilmSeries">@_localizer["FilmSeries"]</div>
|
||||
<div class="enlightenment-option" data-value="FilmFranchise">@_localizer["FilmFranchise"]</div>
|
||||
<div class="enlightenment-option" data-value="Concert">@_localizer["Concert"]</div>
|
||||
<div class="enlightenment-option" data-value="ConcertVideo">@_localizer["Concert"]</div>
|
||||
<div class="enlightenment-option" data-value="Documentary">@_localizer["Documentary"]</div>
|
||||
<div class="enlightenment-option" data-value="Tutorial">@_localizer["Tutorial"]</div>
|
||||
<div class="enlightenment-option" data-value="Personal">@_localizer["Personal"]</div>
|
||||
<div class="enlightenment-option" data-value="TutorialVideo">@_localizer["Tutorial"]</div>
|
||||
<div class="enlightenment-option" data-value="HomeVideo">@_localizer["Personal"]</div>
|
||||
<div class="enlightenment-option" data-value="Anime">@_localizer["Anime"]</div>
|
||||
<div class="enlightenment-option" data-value="Youtube">@_localizer["Youtube"]</div>
|
||||
<div class="enlightenment-option" data-value="Videoclip">@_localizer["Videoclip"]</div>
|
||||
<div class="enlightenment-option" data-value="YouTubeVideo">@_localizer["Youtube"]</div>
|
||||
<div class="enlightenment-option" data-value="MusicVideo">@_localizer["Videoclip"]</div>
|
||||
<div class="enlightenment-option disabled">@_localizer["AudioContent"]</div>
|
||||
<div class="enlightenment-option" data-value="Music">@_localizer["Music"]</div>
|
||||
<div class="enlightenment-option" data-value="AudioBook">@_localizer["AudioBook"]</div>
|
||||
<div class="enlightenment-option" data-value="LivePerformance">@_localizer["LivePerformance"]</div>
|
||||
<div class="enlightenment-option" data-value="Interview">@_localizer["Interview"]</div>
|
||||
<div class="enlightenment-option" data-value="Cover">@_localizer["Cover"]</div>
|
||||
<div class="enlightenment-option" data-value="Audiobook">@_localizer["AudioBook"]</div>
|
||||
<div class="enlightenment-option" data-value="LiveRecordingAudio">@_localizer["LivePerformance"]</div>
|
||||
<div class="enlightenment-option" data-value="InterviewAudio">@_localizer["Interview"]</div>
|
||||
<div class="enlightenment-option" data-value="CoverSongAudio">@_localizer["Cover"]</div>
|
||||
<div class="enlightenment-option" data-value="Remix">@_localizer["Remix"]</div>
|
||||
<div class="enlightenment-option" data-value="Soundeffect">@_localizer["Soundeffect"]</div>
|
||||
<div class="enlightenment-option" data-value="Podcast">@_localizer["Podcast"]</div>
|
||||
<div class="enlightenment-option" data-value="SoundEffect">@_localizer["Soundeffect"]</div>
|
||||
<div class="enlightenment-option" data-value="PodcastAudio">@_localizer["Podcast"]</div>
|
||||
<div class="enlightenment-option" data-value="RadioShow">@_localizer["RadioShow"]</div>
|
||||
<div class="enlightenment-option disabled">@_localizer["VisualContent"]</div>
|
||||
<div class="enlightenment-option" data-value="PhotoAlbum">@_localizer["PhotoAlbum"]</div>
|
||||
<div class="enlightenment-option" data-value="Photo">@_localizer["PhotoAlbum"]</div>
|
||||
<div class="enlightenment-option disabled">@_localizer["MiscellaneousContent"]</div>
|
||||
<div class="enlightenment-option last-option" data-value="Other">@_localizer["Other"]</div>
|
||||
</div>
|
||||
@@ -103,7 +103,7 @@
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionLibraryType"]</small>
|
||||
</div>
|
||||
<!-- Cover -->
|
||||
<!-- Cover. -->
|
||||
<div class="form-row mt-10">
|
||||
<div class="form-label">
|
||||
<label asp-for="CoverImage">@_localizer["CoverImage"]</label>:
|
||||
@@ -122,7 +122,7 @@
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionCover"]</small>
|
||||
</div>
|
||||
<!-- Directories -->
|
||||
<!-- Directories. -->
|
||||
<div class="form-row mt-10">
|
||||
<div class="form-label">
|
||||
<label asp-for="ContentLocations">@_localizer["Directories"]</label>
|
||||
@@ -204,6 +204,38 @@
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionShouldSkipUnchangedDirectoriesDuringScan"]</small>
|
||||
</div>
|
||||
<!-- Path template. -->
|
||||
<style>
|
||||
.path-template-palette { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
|
||||
.path-template-palette-pill { cursor: grab; padding: 4px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); color: #d9d9d9; font-size: 12px; user-select: none; }
|
||||
.path-template-dropzone { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 42px; padding: 8px; border: 1px dashed rgba(255, 255, 255, 0.25); border-radius: 8px; }
|
||||
.path-template-pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.10); border: 1px solid rgba(255, 255, 255, 0.22); cursor: grab; }
|
||||
.path-template-part-label { font-size: 11px; color: #9fb3c8; white-space: nowrap; }
|
||||
.path-template-literal-input { width: 90px; height: 20px; font-size: 12px; padding: 0 4px; }
|
||||
.path-template-width { width: 42px; height: 20px; font-size: 12px; padding: 0 4px; }
|
||||
.path-template-separator-chip { display: inline-block; padding: 1px 7px; border-radius: 8px; background: rgba(255, 255, 255, 0.14); color: #d9d9d9; font-size: 12px; }
|
||||
.path-template-pill .path-template-remove { cursor: pointer; width: 12px; height: 12px; }
|
||||
.path-template-drop-before { box-shadow: -3px 0 0 0 #7fd6ff; }
|
||||
.path-template-drop-after { box-shadow: 3px 0 0 0 #7fd6ff; }
|
||||
.path-template-preview { margin-top: 8px; color: #d9d9d9; font-size: 13px; }
|
||||
.path-template-preview code { color: #7fd6ff; }
|
||||
</style>
|
||||
<!-- The path template editor is only relevant for library types that have a path part catalog, so it starts hidden and is shown by the script when one exists. -->
|
||||
<div id="path-template-section" class="hidden">
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label>@_localizer["PathTemplate"]:</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div id="path-template-palette" class="path-template-palette w-100"></div>
|
||||
<div id="path-template-dropzone" class="path-template-dropzone w-100"></div>
|
||||
<div class="path-template-preview">
|
||||
<span>@_localizer["PathTemplatePreview"]:</span> <code id="path-template-preview-value"></code>
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionPathTemplate"]</small>
|
||||
</div>
|
||||
</div>
|
||||
@if (id is not null)
|
||||
{
|
||||
<h3 class="text-light-two">@_localizer["MetadataProviders"]</h3>
|
||||
@@ -217,7 +249,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- metadata providers will be populated here -->
|
||||
<!-- Metadata providers will be populated here. -->
|
||||
</tbody>
|
||||
</table>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionMetadataProviders"]</small>
|
||||
@@ -233,7 +265,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- artwork providers will be populated here -->
|
||||
<!-- Artwork providers will be populated here. -->
|
||||
</tbody>
|
||||
</table>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionArtworkProviders"]</small>
|
||||
@@ -249,7 +281,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- book readers will be populated here -->
|
||||
<!-- Book readers will be populated here. -->
|
||||
</tbody>
|
||||
</table>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionBookReaders"]</small>
|
||||
@@ -260,7 +292,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!-- section success -->
|
||||
<!-- Section success. -->
|
||||
<div class="text-center w-100">
|
||||
<p id="save-success" class="text-light-one w-100 hidden">@_localizer["LibrarySaved"]</p>
|
||||
<button id="btn-back-to-libraries" type="button" class="abort-button h-22px w-180px mx-auto mt-10 hidden">@_localizer["BackToLibraries"]</button>
|
||||
@@ -307,7 +339,15 @@
|
||||
IsLocked: chkIsLocked.checked,
|
||||
CanDownloadMetadataFromWeb: chkCanDownloadMetadataFromWeb.checked,
|
||||
ShouldSaveMetadataInMediaDirectories: chkShouldSaveMetadataInMediaDirectories.checked,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: chkShouldSkipUnchangedDirectoriesDuringScan.checked
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: chkShouldSkipUnchangedDirectoriesDuringScan.checked,
|
||||
PathTemplateParts: Array.from(pathTemplateDropzone.querySelectorAll('.path-template-pill')).map(pill => {
|
||||
const optional = pill.querySelector('.path-template-optional');
|
||||
return {
|
||||
Kind: pill.dataset.kind,
|
||||
Representation: getPathTemplatePillRepresentation(pill),
|
||||
IsOptional: optional ? optional.checked : false
|
||||
};
|
||||
})
|
||||
};
|
||||
const data = await callApiPostAsync('@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.SAVE_LIBRARY)', formData);
|
||||
if (data) {
|
||||
@@ -404,7 +444,7 @@
|
||||
async function loadMetadataProvidersAsync() {
|
||||
if (!id || !metadataProvidersTbody) return;
|
||||
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_METADATA_PROVIDERS, new { libraryId = default(Guid) })'
|
||||
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
|
||||
.replace('/@(default(Guid))', `/${id}`); // The libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
|
||||
const response = await callApiGetAsync(url);
|
||||
if (response && response.length > 0) {
|
||||
metadataProvidersTbody.innerHTML = response.map((provider, index) => renderMetadataProviderRow(provider, index, response.length)).join('');
|
||||
@@ -475,7 +515,7 @@
|
||||
async function loadArtworkProvidersAsync() {
|
||||
if (!id || !artworkProvidersTbody) return;
|
||||
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_ARTWORK_PROVIDERS, new { libraryId = default(Guid) })'
|
||||
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
|
||||
.replace('/@(default(Guid))', `/${id}`); // The libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
|
||||
const response = await callApiGetAsync(url);
|
||||
if (response && response.length > 0) {
|
||||
artworkProvidersTbody.innerHTML = response.map((provider, index) => renderArtworkProviderRow(provider, index, response.length)).join('');
|
||||
@@ -546,7 +586,7 @@
|
||||
async function loadBookReadersAsync() {
|
||||
if (!id || !bookReadersTbody) return;
|
||||
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_BOOK_READERS, new { libraryId = default(Guid) })'
|
||||
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
|
||||
.replace('/@(default(Guid))', `/${id}`); // The libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
|
||||
const response = await callApiGetAsync(url);
|
||||
if (response && response.length > 0) {
|
||||
bookReadersTbody.innerHTML = response.map(reader => renderBookReaderRow(reader)).join('');
|
||||
@@ -582,6 +622,340 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Path template editor.
|
||||
const pathTemplateSection = document.getElementById('path-template-section');
|
||||
const pathTemplatePalette = document.getElementById('path-template-palette');
|
||||
const pathTemplateDropzone = document.getElementById('path-template-dropzone');
|
||||
const pathTemplatePreviewValue = document.getElementById('path-template-preview-value');
|
||||
const libraryTypeSelectedItem = document.getElementById('library-selected-item');
|
||||
// The type the library was loaded with, so that the saved template is only restored for it, and not when the user previews other types.
|
||||
const initialLibraryType = libraryTypeSelectedItem ? libraryTypeSelectedItem.getAttribute('data-value') : null;
|
||||
const libraryTypeDropdown = form.querySelector('.enlightenment-combobox .enlightenment-dropdown');
|
||||
const pathSeparator = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(System.IO.Path.DirectorySeparatorChar.ToString()));
|
||||
const savedPathTemplateParts = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model.PathTemplateParts, new System.Text.Json.JsonSerializerOptions { PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase }));
|
||||
// The localized strings used inside this script must be injected as JSON, not as raw HTML text: Razor HTML-encodes non-ASCII
|
||||
// characters into numeric entities (e.g. "ă" becomes "ă"), and the browser does not decode entities inside a
|
||||
// script element, so they would show up literally. JSON escapes them as \uXXXX, which the script reads correctly.
|
||||
const pathPartLabels = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(new System.Collections.Generic.Dictionary<string, string>
|
||||
{
|
||||
["Literal"] = _localizer["PathPartLiteral"].Value,
|
||||
["Separator"] = _localizer["PathPartSeparator"].Value,
|
||||
["Artist"] = _localizer["PathPartArtist"].Value,
|
||||
["ReleaseType"] = _localizer["PathPartReleaseType"].Value,
|
||||
["ReleaseYear"] = _localizer["PathPartReleaseYear"].Value,
|
||||
["ReleaseName"] = _localizer["PathPartReleaseName"].Value,
|
||||
["TrackNumber"] = _localizer["PathPartTrackNumber"].Value,
|
||||
["TrackName"] = _localizer["PathPartTrackName"].Value,
|
||||
["Extension"] = _localizer["PathPartExtension"].Value,
|
||||
["DiscNumber"] = _localizer["PathPartDiscNumber"].Value,
|
||||
["Author"] = _localizer["PathPartAuthor"].Value,
|
||||
["Title"] = _localizer["PathPartTitle"].Value,
|
||||
["Series"] = _localizer["PathPartSeries"].Value,
|
||||
["SeriesNumber"] = _localizer["PathPartSeriesNumber"].Value,
|
||||
["BookId"] = _localizer["PathPartBookId"].Value
|
||||
}));
|
||||
const pathTemplateStrings = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(new System.Collections.Generic.Dictionary<string, string>
|
||||
{
|
||||
["optional"] = _localizer["PathPartOptional"].Value,
|
||||
["remove"] = _localizer["Remove"].Value,
|
||||
["literal"] = _localizer["PathPartLiteralPlaceholder"].Value,
|
||||
["digits"] = _localizer["PathPartDigits"].Value
|
||||
}));
|
||||
// The preview shows an example path built from a real example of each library type, so the user sees the effect of the template.
|
||||
const pathTemplateSamples = {
|
||||
Music: {
|
||||
Artist: 'QUEEN',
|
||||
ReleaseType: 'Album',
|
||||
ReleaseYear: '1975',
|
||||
ReleaseName: 'A night at the opera',
|
||||
TrackNumber: '11',
|
||||
TrackName: 'Bohemian rhapsody',
|
||||
DiscNumber: '1',
|
||||
Extension: 'mp3'
|
||||
},
|
||||
Book: {
|
||||
Author: 'J. R. R. Tolkien',
|
||||
Title: 'The Fellowship of the Ring',
|
||||
Series: 'The Lord of the Rings',
|
||||
SeriesNumber: '1',
|
||||
BookId: '42',
|
||||
Extension: 'epub'
|
||||
}
|
||||
};
|
||||
let currentPathTemplateSample = {};
|
||||
const pathTemplateCatalogCache = {};
|
||||
const pathPartValueTypes = {};
|
||||
let draggedPathTemplatePill = null;
|
||||
|
||||
// Gets the localized display name of a path part kind.
|
||||
function pathTemplateKindLabel(kind) {
|
||||
return pathPartLabels[kind] || kind;
|
||||
}
|
||||
|
||||
// Parses a value mask like "Disc {0:00}" into its literal prefix, digit width, and literal suffix.
|
||||
function parsePathTemplateMask(representation) {
|
||||
const match = (representation || '').match(/^(.*)\{0(?::(0+))?\}(.*)$/);
|
||||
if (!match)
|
||||
return { prefix: representation || '', width: 0, suffix: '' };
|
||||
return { prefix: match[1], width: match[2] ? match[2].length : 0, suffix: match[3] };
|
||||
}
|
||||
|
||||
// Rebuilds a value mask from its literal prefix, digit width, and literal suffix.
|
||||
function buildPathTemplateMask(prefix, width, suffix) {
|
||||
return (prefix || '') + '{0' + (width > 0 ? ':' + '0'.repeat(width) : '') + '}' + (suffix || '');
|
||||
}
|
||||
|
||||
// Creates an editable pill for one part of the path template, as it is placed in the drop zone.
|
||||
function renderPathTemplatePill(part) {
|
||||
const pill = document.createElement('div');
|
||||
pill.className = 'path-template-pill';
|
||||
pill.setAttribute('draggable', 'true');
|
||||
pill.dataset.kind = part.kind;
|
||||
pill.title = pathTemplateKindLabel(part.kind);
|
||||
|
||||
// The human readable name of the part, so the user knows what each pill means.
|
||||
const label = document.createElement('span');
|
||||
label.className = 'path-template-part-label';
|
||||
label.textContent = pathTemplateKindLabel(part.kind);
|
||||
pill.appendChild(label);
|
||||
|
||||
if (part.kind === 'Separator') {
|
||||
// A folder separator is shown as its own glyph, never as a raw mask.
|
||||
const separator = document.createElement('span');
|
||||
separator.className = 'path-template-separator-chip';
|
||||
separator.textContent = pathSeparator;
|
||||
pill.appendChild(separator);
|
||||
} else if (part.kind === 'Literal') {
|
||||
// An arbitrary text segment, like the "Disk " glue, is edited directly.
|
||||
const input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
input.className = 'enlightenment-input path-template-literal-input';
|
||||
input.value = part.representation || '';
|
||||
input.placeholder = pathTemplateStrings.literal;
|
||||
input.addEventListener('input', updatePathTemplatePreview);
|
||||
pill.appendChild(input);
|
||||
} else {
|
||||
// Numeric parts can be told how many digits they always use, so values like "01" are understood.
|
||||
if (pathPartValueTypes[part.kind] === 'Integer') {
|
||||
const parsed = parsePathTemplateMask(part.representation);
|
||||
const widthInput = document.createElement('input');
|
||||
widthInput.type = 'number';
|
||||
widthInput.min = '0';
|
||||
widthInput.max = '10';
|
||||
widthInput.className = 'enlightenment-input path-template-width';
|
||||
widthInput.value = parsed.width;
|
||||
widthInput.title = pathTemplateStrings.digits;
|
||||
widthInput.placeholder = pathTemplateStrings.digits;
|
||||
widthInput.addEventListener('input', updatePathTemplatePreview);
|
||||
pill.appendChild(widthInput);
|
||||
}
|
||||
}
|
||||
|
||||
const optionalLabel = document.createElement('label');
|
||||
optionalLabel.className = 'enlightenment-checkbox-label';
|
||||
optionalLabel.title = pathTemplateStrings.optional;
|
||||
const optionalInput = document.createElement('input');
|
||||
optionalInput.type = 'checkbox';
|
||||
optionalInput.className = 'enlightenment-checkbox-hidden path-template-optional';
|
||||
optionalInput.checked = !!part.isOptional;
|
||||
optionalInput.addEventListener('change', updatePathTemplatePreview);
|
||||
const optionalSpan = document.createElement('span');
|
||||
optionalSpan.className = 'enlightenment-checkbox';
|
||||
optionalLabel.appendChild(optionalInput);
|
||||
optionalLabel.appendChild(optionalSpan);
|
||||
pill.appendChild(optionalLabel);
|
||||
const remove = document.createElement('img');
|
||||
remove.src = '/images/ui/delete.svg';
|
||||
remove.alt = pathTemplateStrings.remove;
|
||||
remove.title = pathTemplateStrings.remove;
|
||||
remove.className = 'path-template-remove';
|
||||
remove.addEventListener('click', () => { pill.remove(); updatePathTemplatePreview(); });
|
||||
pill.appendChild(remove);
|
||||
pill.addEventListener('dragstart', (e) => {
|
||||
draggedPathTemplatePill = pill;
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
e.dataTransfer.setData('text/plain', 'pill');
|
||||
});
|
||||
pill.addEventListener('dragend', () => { draggedPathTemplatePill = null; clearPathTemplateDropIndicator(); });
|
||||
return pill;
|
||||
}
|
||||
|
||||
// Builds the stored representation mask of a pill from its human friendly editors.
|
||||
function getPathTemplatePillRepresentation(pill) {
|
||||
const kind = pill.dataset.kind;
|
||||
if (kind === 'Separator')
|
||||
return '';
|
||||
if (kind === 'Literal') {
|
||||
const input = pill.querySelector('.path-template-literal-input');
|
||||
return input ? input.value : '';
|
||||
}
|
||||
const width = pill.querySelector('.path-template-width');
|
||||
return buildPathTemplateMask('', width ? Math.max(0, parseInt(width.value || '0', 10)) : 0, '');
|
||||
}
|
||||
|
||||
// Replaces the parts in the drop zone with the provided parts.
|
||||
function renderPathTemplateParts(parts) {
|
||||
if (!pathTemplateDropzone) return;
|
||||
pathTemplateDropzone.innerHTML = '';
|
||||
(parts || []).forEach(part => pathTemplateDropzone.appendChild(renderPathTemplatePill(part)));
|
||||
updatePathTemplatePreview();
|
||||
}
|
||||
|
||||
// Renders the palette of the parts that can be added to the path template.
|
||||
function renderPathTemplatePalette(parts) {
|
||||
if (!pathTemplatePalette) return;
|
||||
pathTemplatePalette.innerHTML = '';
|
||||
(parts || []).forEach(definition => {
|
||||
const pill = document.createElement('div');
|
||||
pill.className = 'path-template-palette-pill';
|
||||
pill.setAttribute('draggable', 'true');
|
||||
pill.textContent = pathTemplateKindLabel(definition.kind);
|
||||
pill.addEventListener('dragstart', (e) => {
|
||||
e.dataTransfer.effectAllowed = 'copy';
|
||||
e.dataTransfer.setData('application/json', JSON.stringify({
|
||||
source: 'palette',
|
||||
kind: definition.kind,
|
||||
representation: definition.defaultRepresentation,
|
||||
isOptional: definition.isOptionalByDefault
|
||||
}));
|
||||
});
|
||||
pathTemplatePalette.appendChild(pill);
|
||||
});
|
||||
}
|
||||
|
||||
// Formats the sample value of a part according to its mask, for the preview.
|
||||
function formatPathTemplateValue(representation, value) {
|
||||
const match = representation.match(/\{0(?::(0+))?\}/);
|
||||
if (!match)
|
||||
return representation + value;
|
||||
const formatted = match[1] ? String(value).padStart(match[1].length, '0') : value;
|
||||
return representation.slice(0, match.index) + formatted + representation.slice(match.index + match[0].length);
|
||||
}
|
||||
|
||||
// Rebuilds the preview path from the pills currently in the drop zone.
|
||||
function updatePathTemplatePreview() {
|
||||
if (!pathTemplatePreviewValue || !pathTemplateDropzone) return;
|
||||
let result = '';
|
||||
pathTemplateDropzone.querySelectorAll('.path-template-pill').forEach(pill => {
|
||||
const kind = pill.dataset.kind;
|
||||
if (kind === 'Separator') { result += pathSeparator; return; }
|
||||
const representation = getPathTemplatePillRepresentation(pill);
|
||||
if (kind === 'Literal') { result += representation; return; }
|
||||
result += formatPathTemplateValue(representation, currentPathTemplateSample[kind] || '');
|
||||
});
|
||||
pathTemplatePreviewValue.textContent = result;
|
||||
}
|
||||
|
||||
// Loads the path template catalog of the selected library type, and the template to display in the editor.
|
||||
async function loadPathTemplateAsync() {
|
||||
if (!libraryTypeSelectedItem || !pathTemplateDropzone) return;
|
||||
const libraryType = libraryTypeSelectedItem.getAttribute('data-value');
|
||||
if (!libraryType) return;
|
||||
currentPathTemplateSample = pathTemplateSamples[libraryType] || {};
|
||||
let catalog = pathTemplateCatalogCache[libraryType];
|
||||
if (!catalog) {
|
||||
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_LIBRARY_PATH_TEMPLATE_PARTS, new { libraryType = "Music" })'.replace('/Music', `/${libraryType}`);
|
||||
catalog = await callApiGetAsync(url);
|
||||
if (!catalog) catalog = { parts: [], defaultTemplateParts: [] };
|
||||
pathTemplateCatalogCache[libraryType] = catalog;
|
||||
}
|
||||
// Only library types that define path parts get the editor; the others have no structure to describe.
|
||||
const hasParts = (catalog.parts || []).length > 0;
|
||||
if (pathTemplateSection) pathTemplateSection.classList.toggle('hidden', !hasParts);
|
||||
if (!hasParts) {
|
||||
renderPathTemplatePalette([]);
|
||||
renderPathTemplateParts([]);
|
||||
return;
|
||||
}
|
||||
(catalog.parts || []).forEach(definition => { pathPartValueTypes[definition.kind] = definition.valueType; });
|
||||
renderPathTemplatePalette(catalog.parts);
|
||||
// The stored template belongs to the library type it was saved for, so it is only restored for that type.
|
||||
const parts = (savedPathTemplateParts && savedPathTemplateParts.length > 0 && libraryType === initialLibraryType)
|
||||
? savedPathTemplateParts
|
||||
: catalog.defaultTemplateParts;
|
||||
renderPathTemplateParts(parts);
|
||||
}
|
||||
|
||||
// Finds the pill a drag or drop should be placed relative to, based on the pointer position. This also places a part dropped in a
|
||||
// gap between pills, or anywhere in the drop zone, next to the nearest pill, instead of always sending it to the end.
|
||||
function getPathTemplateInsertReference(e, excludePill) {
|
||||
const pills = Array.from(pathTemplateDropzone.querySelectorAll('.path-template-pill')).filter(pill => pill !== excludePill);
|
||||
if (pills.length === 0) return null;
|
||||
let nearestPill = null;
|
||||
let nearestRect = null;
|
||||
let nearestDistance = Infinity;
|
||||
for (const pill of pills) {
|
||||
const rect = pill.getBoundingClientRect();
|
||||
const distance = Math.hypot(e.clientX - (rect.left + rect.width / 2), e.clientY - (rect.top + rect.height / 2));
|
||||
if (distance < nearestDistance) {
|
||||
nearestDistance = distance;
|
||||
nearestPill = pill;
|
||||
nearestRect = rect;
|
||||
}
|
||||
}
|
||||
return { pill: nearestPill, placeAfter: e.clientX > (nearestRect.left + nearestRect.width / 2) };
|
||||
}
|
||||
|
||||
// Removes the insertion indicator from all pills.
|
||||
function clearPathTemplateDropIndicator() {
|
||||
pathTemplateDropzone.querySelectorAll('.path-template-pill').forEach(pill => pill.classList.remove('path-template-drop-before', 'path-template-drop-after'));
|
||||
}
|
||||
|
||||
// Highlights the side of the pill the dragged part would be inserted on.
|
||||
function updatePathTemplateDropIndicator(e) {
|
||||
clearPathTemplateDropIndicator();
|
||||
const reference = getPathTemplateInsertReference(e, draggedPathTemplatePill);
|
||||
if (reference)
|
||||
reference.pill.classList.add(reference.placeAfter ? 'path-template-drop-after' : 'path-template-drop-before');
|
||||
}
|
||||
|
||||
// On a drag over the path template drop zone, allows the drop and shows where the part would be inserted.
|
||||
const handlePathTemplateDragOver = function(e) {
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = draggedPathTemplatePill ? 'move' : 'copy';
|
||||
updatePathTemplateDropIndicator(e);
|
||||
};
|
||||
|
||||
// On a drop over the path template drop zone, inserts a palette part or moves a pill at the pointer position.
|
||||
const handlePathTemplateDrop = function(e) {
|
||||
e.preventDefault();
|
||||
const reference = getPathTemplateInsertReference(e, draggedPathTemplatePill);
|
||||
clearPathTemplateDropIndicator();
|
||||
const insertAtReference = (pill) => {
|
||||
if (reference)
|
||||
reference.pill.insertAdjacentElement(reference.placeAfter ? 'afterend' : 'beforebegin', pill);
|
||||
else
|
||||
pathTemplateDropzone.appendChild(pill);
|
||||
};
|
||||
const raw = e.dataTransfer.getData('application/json');
|
||||
if (raw) {
|
||||
const part = JSON.parse(raw);
|
||||
if (part.source === 'palette') {
|
||||
insertAtReference(renderPathTemplatePill(part));
|
||||
updatePathTemplatePreview();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (draggedPathTemplatePill) {
|
||||
insertAtReference(draggedPathTemplatePill);
|
||||
draggedPathTemplatePill = null;
|
||||
updatePathTemplatePreview();
|
||||
}
|
||||
};
|
||||
|
||||
// On dragging out of the drop zone, removes the insertion indicator.
|
||||
const handlePathTemplateDragLeave = function(e) {
|
||||
if (!pathTemplateDropzone.contains(e.relatedTarget))
|
||||
clearPathTemplateDropIndicator();
|
||||
};
|
||||
|
||||
// On selecting another library type, the available parts and the default template change.
|
||||
const handleLibraryTypeChange = function(e) {
|
||||
const option = e.target.closest('.enlightenment-option');
|
||||
if (!option || option.classList.contains('disabled') || !option.getAttribute('data-value')) return;
|
||||
setTimeout(() => { loadPathTemplateAsync(); }, 0);
|
||||
};
|
||||
|
||||
// Add listeners.
|
||||
form.addEventListener('keypress', handleEnterKey);
|
||||
form.addEventListener('submit', handleSubmit);
|
||||
@@ -591,6 +965,10 @@
|
||||
imgAddCover.addEventListener('click', handleImgAddCoverClick);
|
||||
mediaCoverFormTable.addEventListener('click', handleRowRemoval);
|
||||
mediaDirectoriesFormTable.addEventListener('click', handleRowRemoval);
|
||||
pathTemplateDropzone.addEventListener('dragover', handlePathTemplateDragOver);
|
||||
pathTemplateDropzone.addEventListener('drop', handlePathTemplateDrop);
|
||||
pathTemplateDropzone.addEventListener('dragleave', handlePathTemplateDragLeave);
|
||||
if (libraryTypeDropdown) libraryTypeDropdown.addEventListener('click', handleLibraryTypeChange);
|
||||
if (metadataProvidersTbody) {
|
||||
metadataProvidersTbody.addEventListener('click', handleMetadataProviderReorderAsync);
|
||||
metadataProvidersTbody.addEventListener('change', handleMetadataProviderEnabledChangeAsync);
|
||||
@@ -613,6 +991,10 @@
|
||||
imgAddCover.removeEventListener('click', handleImgAddCoverClick);
|
||||
mediaCoverFormTable.removeEventListener('click', handleRowRemoval);
|
||||
mediaDirectoriesFormTable.removeEventListener('click', handleRowRemoval);
|
||||
pathTemplateDropzone.removeEventListener('dragover', handlePathTemplateDragOver);
|
||||
pathTemplateDropzone.removeEventListener('drop', handlePathTemplateDrop);
|
||||
pathTemplateDropzone.removeEventListener('dragleave', handlePathTemplateDragLeave);
|
||||
if (libraryTypeDropdown) libraryTypeDropdown.removeEventListener('click', handleLibraryTypeChange);
|
||||
if (metadataProvidersTbody) {
|
||||
metadataProvidersTbody.removeEventListener('click', handleMetadataProviderReorderAsync);
|
||||
metadataProvidersTbody.removeEventListener('change', handleMetadataProviderEnabledChangeAsync);
|
||||
@@ -633,6 +1015,9 @@
|
||||
loadBookReadersAsync();
|
||||
}
|
||||
|
||||
// Load the path template of the selected library type, and its default, for both new and existing libraries.
|
||||
loadPathTemplateAsync();
|
||||
|
||||
// Store all cleanups for this view on window object using the scriptId.
|
||||
window.viewCleanups = window.viewCleanups || {};
|
||||
window.viewCleanups['@scriptId'] = () => {
|
||||
|
||||
@@ -294,6 +294,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "management", "management",
|
||||
..\docs\technical\requests\library\management\GetEnabledLibraries.http = ..\docs\technical\requests\library\management\GetEnabledLibraries.http
|
||||
..\docs\technical\requests\library\management\GetLibraries.http = ..\docs\technical\requests\library\management\GetLibraries.http
|
||||
..\docs\technical\requests\library\management\GetLibrary.http = ..\docs\technical\requests\library\management\GetLibrary.http
|
||||
..\docs\technical\requests\library\management\GetLibraryPathTemplateParts.http = ..\docs\technical\requests\library\management\GetLibraryPathTemplateParts.http
|
||||
..\docs\technical\requests\library\management\GetLibraryScanProgress.http = ..\docs\technical\requests\library\management\GetLibraryScanProgress.http
|
||||
..\docs\technical\requests\library\management\GetRunningLibraryScans.http = ..\docs\technical\requests\library\management\GetRunningLibraryScans.http
|
||||
..\docs\technical\requests\library\management\ScanLibraries.http = ..\docs\technical\requests\library\management\ScanLibraries.http
|
||||
|
||||
+7
-2
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
@@ -27,6 +28,7 @@ public class AddLibraryCommandFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public AddLibraryCommand Create(
|
||||
string? title = null,
|
||||
@@ -37,7 +39,8 @@ public class AddLibraryCommandFixture
|
||||
bool isLocked = false,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
LibraryPathTemplatePartDto[]? pathTemplateParts = null)
|
||||
{
|
||||
return new Faker<AddLibraryCommand>()
|
||||
.CustomInstantiator(f => new AddLibraryCommand(
|
||||
@@ -49,7 +52,8 @@ public class AddLibraryCommandFixture
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
null
|
||||
))
|
||||
.RuleFor(x => x.Title, f => title ?? f.Lorem.Word())
|
||||
.RuleFor(x => x.LibraryType, f => libraryType ?? f.Random.Enum<LibraryType>().ToString())
|
||||
@@ -60,6 +64,7 @@ public class AddLibraryCommandFixture
|
||||
.RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb)
|
||||
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
|
||||
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
|
||||
.RuleFor(x => x.PathTemplateParts, pathTemplateParts)
|
||||
.Generate();
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
@@ -30,6 +31,7 @@ public class UpdateLibraryCommandFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public UpdateLibraryCommand Create(
|
||||
Guid? id = null,
|
||||
@@ -42,7 +44,8 @@ public class UpdateLibraryCommandFixture
|
||||
bool isLocked = false,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
LibraryPathTemplatePartDto[]? pathTemplateParts = null)
|
||||
{
|
||||
return new Faker<UpdateLibraryCommand>()
|
||||
.CustomInstantiator(f => new UpdateLibraryCommand(
|
||||
@@ -56,7 +59,8 @@ public class UpdateLibraryCommandFixture
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
null
|
||||
))
|
||||
.RuleFor(x => x.Id, id ?? Guid.NewGuid())
|
||||
.RuleFor(x => x.OwnerId, ownerId ?? Guid.NewGuid())
|
||||
@@ -69,6 +73,7 @@ public class UpdateLibraryCommandFixture
|
||||
.RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb)
|
||||
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
|
||||
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
|
||||
.RuleFor(x => x.PathTemplateParts, pathTemplateParts)
|
||||
.Generate();
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -28,6 +28,7 @@ public class AddLibraryRequestFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <returns>The created <see cref="AddLibraryRequest"/>.</returns>
|
||||
public AddLibraryRequest Create(
|
||||
string? title = null,
|
||||
@@ -38,7 +39,8 @@ public class AddLibraryRequestFixture
|
||||
bool? isLocked = null,
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null)
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
|
||||
LibraryPathTemplatePartRequest[]? pathTemplateParts = null)
|
||||
{
|
||||
return new AddLibraryRequest(
|
||||
title ?? _faker.Commerce.Department(),
|
||||
@@ -49,7 +51,8 @@ public class AddLibraryRequestFixture
|
||||
isLocked ?? _faker.Random.Bool(),
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool()
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
|
||||
pathTemplateParts
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -31,6 +31,7 @@ public class UpdateLibraryRequestFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <returns>The created <see cref="UpdateLibraryRequest"/>.</returns>
|
||||
public UpdateLibraryRequest Create(
|
||||
Guid? id = null,
|
||||
@@ -43,7 +44,8 @@ public class UpdateLibraryRequestFixture
|
||||
bool? isLocked = null,
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null)
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
|
||||
LibraryPathTemplatePartRequest[]? pathTemplateParts = null)
|
||||
{
|
||||
return new UpdateLibraryRequest(
|
||||
id ?? _faker.Random.Guid(),
|
||||
@@ -56,7 +58,8 @@ public class UpdateLibraryRequestFixture
|
||||
isLocked ?? _faker.Random.Bool(),
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool()
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
|
||||
pathTemplateParts
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -32,6 +32,7 @@ public class LibraryResponseFixture
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="pathTemplateParts">Optional. The ordered parts of the path template of the media library.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the library was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the library was updated.</param>
|
||||
/// <returns>The created <see cref="LibraryResponse"/>.</returns>
|
||||
@@ -47,6 +48,7 @@ public class LibraryResponseFixture
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
|
||||
List<LibraryPathTemplatePartResponse>? pathTemplateParts = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null)
|
||||
{
|
||||
@@ -62,6 +64,7 @@ public class LibraryResponseFixture
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
|
||||
pathTemplateParts ?? [],
|
||||
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
|
||||
updatedOnUtc
|
||||
);
|
||||
|
||||
+5
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
@@ -42,6 +43,7 @@ public class LibraryFixture
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="scanIds">Optional. The scan Ids associated with the library.</param>
|
||||
/// <param name="pathTemplate">Optional. The path template of the library.</param>
|
||||
/// <param name="includeCoverImage">Whether the cover image should be included, or left unset, meaning the library has no cover.</param>
|
||||
/// <returns>The created <see cref="Library"/>.</returns>
|
||||
public Library Create(
|
||||
@@ -57,6 +59,7 @@ public class LibraryFixture
|
||||
bool shouldSaveMetadataInMediaDirectories = false,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
IEnumerable<Guid>? scanIds = null,
|
||||
LibraryPathTemplate? pathTemplate = null,
|
||||
bool includeCoverImage = true)
|
||||
{
|
||||
List<string> validPaths =
|
||||
@@ -83,6 +86,7 @@ public class LibraryFixture
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplate ?? LibraryPathTemplate.Empty(),
|
||||
resolvedScanIds
|
||||
) :
|
||||
Library.Create(
|
||||
@@ -97,6 +101,7 @@ public class LibraryFixture
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplate ?? LibraryPathTemplate.Empty(),
|
||||
resolvedScanIds
|
||||
);
|
||||
|
||||
|
||||
+7
-1
@@ -12,6 +12,8 @@ using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Manage
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
|
||||
@@ -42,6 +44,7 @@ public class AddLibraryCommandHandlerTests
|
||||
private readonly IDomainEventsQueue _mockDomainEventsQueue;
|
||||
private readonly IEnvironmentContext _mockEnvironmentContext;
|
||||
private readonly IMediaLibraryProviderConfigurationStore _mockProviderConfigurationStore;
|
||||
private readonly ILibraryPathTemplateService _mockLibraryPathTemplateService;
|
||||
private readonly IValidator<AddLibraryCommand> _mockValidator;
|
||||
private readonly AddLibraryCommandHandler _sut;
|
||||
private readonly AddLibraryCommandFixture _addLibraryCommandFixture = new();
|
||||
@@ -62,6 +65,7 @@ public class AddLibraryCommandHandlerTests
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
_mockEnvironmentContext = Substitute.For<IEnvironmentContext>();
|
||||
_mockProviderConfigurationStore = Substitute.For<IMediaLibraryProviderConfigurationStore>();
|
||||
_mockLibraryPathTemplateService = Substitute.For<ILibraryPathTemplateService>();
|
||||
_mockValidator = Substitute.For<IValidator<AddLibraryCommand>>();
|
||||
_userId = Guid.NewGuid();
|
||||
|
||||
@@ -75,8 +79,10 @@ public class AddLibraryCommandHandlerTests
|
||||
_mockProviderConfigurationStore.EnsureProviderConfigurationsAsync(Arg.Any<Guid>(), Arg.Any<LibraryType>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Success);
|
||||
_mockValidator.Validate(Arg.Any<AddLibraryCommand>()).Returns([]);
|
||||
_mockLibraryPathTemplateService.GetDefaultTemplate(Arg.Any<LibraryType>()).Returns(LibraryPathTemplate.Empty());
|
||||
_mockLibraryPathTemplateService.Validate(Arg.Any<LibraryType>(), Arg.Any<LibraryPathTemplate>()).Returns(Result.Success);
|
||||
|
||||
_sut = new AddLibraryCommandHandler(_mockAuthorizationService, _mockCurrentUserService, _mockDomainEventsQueue, _mockEnvironmentContext, _mockProviderConfigurationStore, _mockUnitOfWork, _mockValidator);
|
||||
_sut = new AddLibraryCommandHandler(_mockAuthorizationService, _mockCurrentUserService, _mockDomainEventsQueue, _mockEnvironmentContext, _mockProviderConfigurationStore, _mockLibraryPathTemplateService, _mockUnitOfWork, _mockValidator);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+7
-1
@@ -13,6 +13,8 @@ using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Manage
|
||||
using Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.UpdateLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
|
||||
@@ -44,6 +46,7 @@ public class UpdateLibraryCommandHandlerTests
|
||||
private readonly IDomainEventsQueue _mockDomainEventsQueue;
|
||||
private readonly IEnvironmentContext _mockEnvironmentContext;
|
||||
private readonly IMediaLibraryProviderConfigurationStore _mockProviderConfigurationStore;
|
||||
private readonly ILibraryPathTemplateService _mockLibraryPathTemplateService;
|
||||
private readonly IValidator<UpdateLibraryCommand> _mockValidator;
|
||||
private readonly UpdateLibraryCommandHandler _sut;
|
||||
private readonly UpdateLibraryCommandFixture _updateLibraryCommandFixture = new();
|
||||
@@ -64,6 +67,7 @@ public class UpdateLibraryCommandHandlerTests
|
||||
_mockDomainEventsQueue = Substitute.For<IDomainEventsQueue>();
|
||||
_mockEnvironmentContext = Substitute.For<IEnvironmentContext>();
|
||||
_mockProviderConfigurationStore = Substitute.For<IMediaLibraryProviderConfigurationStore>();
|
||||
_mockLibraryPathTemplateService = Substitute.For<ILibraryPathTemplateService>();
|
||||
_mockValidator = Substitute.For<IValidator<UpdateLibraryCommand>>();
|
||||
_userId = Guid.NewGuid();
|
||||
|
||||
@@ -78,8 +82,10 @@ public class UpdateLibraryCommandHandlerTests
|
||||
_mockProviderConfigurationStore.ReconcileProviderConfigurationsAsync(Arg.Any<Guid>(), Arg.Any<LibraryType>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Success);
|
||||
_mockValidator.Validate(Arg.Any<UpdateLibraryCommand>()).Returns([]);
|
||||
_mockLibraryPathTemplateService.GetDefaultTemplate(Arg.Any<LibraryType>()).Returns(LibraryPathTemplate.Empty());
|
||||
_mockLibraryPathTemplateService.Validate(Arg.Any<LibraryType>(), Arg.Any<LibraryPathTemplate>()).Returns(Result.Success);
|
||||
|
||||
_sut = new UpdateLibraryCommandHandler(_mockAuthorizationService, _mockCurrentUserService, _mockDomainEventsQueue, _mockEnvironmentContext, _mockProviderConfigurationStore, _mockUnitOfWork, _mockValidator);
|
||||
_sut = new UpdateLibraryCommandHandler(_mockAuthorizationService, _mockCurrentUserService, _mockDomainEventsQueue, _mockEnvironmentContext, _mockProviderConfigurationStore, _mockLibraryPathTemplateService, _mockUnitOfWork, _mockValidator);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+6
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
@@ -51,6 +52,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: false,
|
||||
shouldSaveMetadataInMediaDirectories: true,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: true,
|
||||
LibraryPathTemplate.Empty(),
|
||||
scanIds);
|
||||
|
||||
// Assert
|
||||
@@ -89,6 +91,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
LibraryPathTemplate.Empty(),
|
||||
scanIds);
|
||||
|
||||
// Assert
|
||||
@@ -115,6 +118,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
LibraryPathTemplate.Empty(),
|
||||
[]);
|
||||
|
||||
// Assert
|
||||
@@ -150,6 +154,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
LibraryPathTemplate.Empty(),
|
||||
[]);
|
||||
|
||||
// Assert
|
||||
@@ -177,6 +182,7 @@ public class LibraryTests
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
LibraryPathTemplate.Empty(),
|
||||
[]);
|
||||
|
||||
// Assert
|
||||
|
||||
Reference in new issue
Block a user