diff --git a/Jellyfin.Plugin.YandexMusic/AlbumArtistTask.cs b/Jellyfin.Plugin.YandexMusic/AlbumArtistTask.cs new file mode 100644 index 0000000..e771c30 --- /dev/null +++ b/Jellyfin.Plugin.YandexMusic/AlbumArtistTask.cs @@ -0,0 +1,86 @@ +using Jellyfin.Data.Enums; +using Jellyfin.Plugin.YandexMusic.Providers; +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; + +/// +/// Fills the AlbumArtists field for existing audio items. Jellyfin's Audio metadata merge +/// ignores this field, which is why artist and album pages stay empty. +/// +public class AlbumArtistTask : IScheduledTask +{ + private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; + + /// + /// Initializes a new instance of the class. + /// + public AlbumArtistTask(ILibraryManager libraryManager, ILogger logger) + { + _libraryManager = libraryManager; + _logger = logger; + } + + /// + public string Name => "Yandex Music: заполнить исполнителей альбомов"; + + /// + public string Key => "YandexMusicAlbumArtists"; + + /// + public string Description => "Заполняет AlbumArtists у треков, чтобы Jellyfin создал исполнителей и альбомы."; + + /// + public string Category => "Yandex Music"; + + /// + public async Task ExecuteAsync(IProgress progress, CancellationToken cancellationToken) + { + var items = _libraryManager.GetItemList(new InternalItemsQuery + { + Recursive = true, + IncludeItemTypes = [BaseItemKind.Audio], + IsVirtualItem = false + }).OfType