Adds dynamic path templates for media libraries, so that the scanner can derive the meaning of each path part

This commit is contained in:
BinaryAlley committed 2026-10-05 18:42:00 +03:00
1 parent 62b0e9297a
commit ca4f308b0a
86 files changed
+7406 -151

No files matched your search

@@ -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);
}
}
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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 "&#x103;"), 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'] = () => {