diff --git a/Jellyfin.Plugin.YandexMusic/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.YandexMusic/Configuration/PluginConfiguration.cs index a6a6486..cf68458 100644 --- a/Jellyfin.Plugin.YandexMusic/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.YandexMusic/Configuration/PluginConfiguration.cs @@ -77,4 +77,9 @@ public class PluginConfiguration : BasePluginConfiguration /// Gets or sets a value indicating whether composers and lyricists are fetched from track credits. /// public bool EnableCredits { get; set; } = true; + + /// + /// Gets or sets the target folder for the "organize into albums" task. + /// + public string OrganizeTargetPath { get; set; } = "/movie/music-organized"; } diff --git a/Jellyfin.Plugin.YandexMusic/Configuration/configPage.html b/Jellyfin.Plugin.YandexMusic/Configuration/configPage.html index 80ca03b..34030ad 100644 --- a/Jellyfin.Plugin.YandexMusic/Configuration/configPage.html +++ b/Jellyfin.Plugin.YandexMusic/Configuration/configPage.html @@ -126,6 +126,11 @@ +
+ + +
Куда задача «разложить по альбомам» создаст хардлинки. По умолчанию /movie/music-organized.
+
@@ -205,6 +210,7 @@ document.querySelector('#UseYandexYear').checked = config.UseYandexYear; document.querySelector('#MatchThreshold').value = config.MatchThreshold; document.querySelector('#DurationToleranceSeconds').value = config.DurationToleranceSeconds; + document.querySelector('#OrganizeTargetPath').value = config.OrganizeTargetPath || '/movie/music-organized'; Dashboard.hideLoadingMsg(); ApiClient.ajax({ type: 'GET', @@ -237,6 +243,7 @@ config.UseYandexYear = document.querySelector('#UseYandexYear').checked; config.MatchThreshold = parseFloat(document.querySelector('#MatchThreshold').value) || 0.72; config.DurationToleranceSeconds = parseInt(document.querySelector('#DurationToleranceSeconds').value, 10) || 12; + config.OrganizeTargetPath = document.querySelector('#OrganizeTargetPath').value || '/movie/music-organized'; ApiClient.updatePluginConfiguration(YandexMusicConfig.pluginId, config).then(function (result) { Dashboard.processPluginConfigurationUpdateResult(result); }); diff --git a/Jellyfin.Plugin.YandexMusic/Jellyfin.Plugin.YandexMusic.csproj b/Jellyfin.Plugin.YandexMusic/Jellyfin.Plugin.YandexMusic.csproj index b9d032a..8dc0a2c 100644 --- a/Jellyfin.Plugin.YandexMusic/Jellyfin.Plugin.YandexMusic.csproj +++ b/Jellyfin.Plugin.YandexMusic/Jellyfin.Plugin.YandexMusic.csproj @@ -1,9 +1,9 @@ - 1.0.0.11 - 1.0.0.11 - 1.0.0.11 + 1.0.0.12 + 1.0.0.12 + 1.0.0.12 net10.0 Jellyfin.Plugin.YandexMusic Jellyfin.Plugin.YandexMusic diff --git a/Jellyfin.Plugin.YandexMusic/OrganizeLibraryTask.cs b/Jellyfin.Plugin.YandexMusic/OrganizeLibraryTask.cs new file mode 100644 index 0000000..f0398db --- /dev/null +++ b/Jellyfin.Plugin.YandexMusic/OrganizeLibraryTask.cs @@ -0,0 +1,155 @@ +using System.Runtime.InteropServices; +using Jellyfin.Data.Enums; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; + +namespace Jellyfin.Plugin.YandexMusic; + +/// +/// Creates a Jellyfin-friendly Artist/Album folder tree using hard links, so albums and artists +/// are built from folders while the original files stay untouched. +/// +public class OrganizeLibraryTask : IScheduledTask +{ + private const string DefaultTargetPath = "/movie/music-organized"; + + private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; + + /// + /// Initializes a new instance of the class. + /// + public OrganizeLibraryTask(ILibraryManager libraryManager, ILogger logger) + { + _libraryManager = libraryManager; + _logger = logger; + } + + /// + public string Name => "Yandex Music: разложить по альбомам"; + + /// + public string Key => "YandexMusicOrganize"; + + /// + public string Description => "Создаёт дерево Исполнитель/Альбом хардлинками, чтобы Jellyfin создал альбомы."; + + /// + public string Category => "Yandex Music"; + + /// + public async Task ExecuteAsync(IProgress progress, CancellationToken cancellationToken) + { + var targetRoot = Plugin.Instance?.Configuration.OrganizeTargetPath; + if (string.IsNullOrWhiteSpace(targetRoot)) + { + targetRoot = DefaultTargetPath; + } + + Directory.CreateDirectory(targetRoot); + + var items = _libraryManager.GetItemList(new InternalItemsQuery + { + Recursive = true, + IncludeItemTypes = [BaseItemKind.Audio], + IsVirtualItem = false + }).OfType