2 Commits
Author SHA1 Message Date
1xDed f5674bec6a Release 1.0.0.6: repair migrated artist and genre links 2026-11-27 19:56:58 +03:00
1xDed 230616e4fc Release 1.0.0.5: artist people links 2026-11-27 19:53:03 +03:00
8 changed files with 89 additions and 28 deletions

No files matched your search

+60 -18
View File
@@ -1,39 +1,43 @@
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using Jellyfin.Plugin.YandexMusic.Providers; using Jellyfin.Plugin.YandexMusic.Providers;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Tasks; using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace Jellyfin.Plugin.YandexMusic; namespace Jellyfin.Plugin.YandexMusic;
/// <summary> /// <summary>
/// Fills the AlbumArtists field for existing audio items. Jellyfin's Audio metadata merge /// Repairs music metadata links after a Jellyfin 10 -> 12 migration:
/// ignores this field, which is why artist and album pages stay empty. /// fills AlbumArtists, writes Artists/Genres into the new item-value tables and creates person links.
/// </summary> /// </summary>
public class AlbumArtistTask : IScheduledTask public class AlbumArtistTask : IScheduledTask
{ {
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IDtoService _dtoService;
private readonly ILogger<AlbumArtistTask> _logger; private readonly ILogger<AlbumArtistTask> _logger;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AlbumArtistTask"/> class. /// Initializes a new instance of the <see cref="AlbumArtistTask"/> class.
/// </summary> /// </summary>
public AlbumArtistTask(ILibraryManager libraryManager, ILogger<AlbumArtistTask> logger) public AlbumArtistTask(ILibraryManager libraryManager, IDtoService dtoService, ILogger<AlbumArtistTask> logger)
{ {
_libraryManager = libraryManager; _libraryManager = libraryManager;
_dtoService = dtoService;
_logger = logger; _logger = logger;
} }
/// <inheritdoc /> /// <inheritdoc />
public string Name => "Yandex Music: заполнить исполнителей альбомов"; public string Name => "Yandex Music: исправить исполнителей и жанры";
/// <inheritdoc /> /// <inheritdoc />
public string Key => "YandexMusicAlbumArtists"; public string Key => "YandexMusicAlbumArtists";
/// <inheritdoc /> /// <inheritdoc />
public string Description => "Заполняет AlbumArtists у треков, чтобы Jellyfin создал исполнителей и альбомы."; public string Description => "Переносит исполнителей, альбомных исполнителей и жанры в новую модель Jellyfin 12 и создаёт связи артистов.";
/// <inheritdoc /> /// <inheritdoc />
public string Category => "Yandex Music"; public string Category => "Yandex Music";
@@ -48,37 +52,75 @@ public class AlbumArtistTask : IScheduledTask
IsVirtualItem = false IsVirtualItem = false
}).OfType<Audio>().ToList(); }).OfType<Audio>().ToList();
var dtoOptions = new DtoOptions(true);
var updated = 0; var updated = 0;
for (var i = 0; i < items.Count; i++) for (var i = 0; i < items.Count; i++)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var item = items[i]; var item = items[i];
string[] artists; var dto = _dtoService.GetBaseItemDto(item, dtoOptions);
if (AlbumArtistCache.TryGet(item.Path, out var cached)) var dtoArtists = (dto.Artists ?? [])
.Where(a => !string.IsNullOrWhiteSpace(a))
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToArray();
var dtoAlbumArtists = (dto.AlbumArtists ?? [])
.Select(a => a.Name)
.Where(n => !string.IsNullOrWhiteSpace(n))
.Select(n => n!)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToArray();
var dtoGenres = (dto.Genres ?? [])
.Where(g => !string.IsNullOrWhiteSpace(g))
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToArray();
if (dtoArtists.Length > 0)
{ {
artists = cached; item.Artists = dtoArtists;
}
if (dtoAlbumArtists.Length > 0)
{
item.AlbumArtists = dtoAlbumArtists;
}
else if (AlbumArtistCache.TryGet(item.Path, out var cached))
{
item.AlbumArtists = cached;
} }
else if (item.Artists.Count > 0) else if (item.Artists.Count > 0)
{ {
artists = [item.Artists[0]]; item.AlbumArtists = [item.Artists[0]];
}
else
{
artists = [];
} }
if (artists.Length > 0 && !item.AlbumArtists.SequenceEqual(artists, StringComparer.OrdinalIgnoreCase)) if (dtoGenres.Length > 0)
{ {
item.AlbumArtists = artists; item.Genres = dtoGenres;
await item.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
updated++;
} }
await item.UpdateToRepositoryAsync(ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
var people = new List<PersonInfo>();
foreach (var name in item.AlbumArtists)
{
people.Add(new PersonInfo { Name = name, Type = PersonKind.AlbumArtist });
}
foreach (var name in item.Artists)
{
people.Add(new PersonInfo { Name = name, Type = PersonKind.Artist });
}
if (people.Count > 0)
{
await _libraryManager.UpdatePeopleAsync(item, people, cancellationToken).ConfigureAwait(false);
}
updated++;
progress.Report(100.0 * (i + 1) / Math.Max(1, items.Count)); progress.Report(100.0 * (i + 1) / Math.Max(1, items.Count));
} }
_logger.LogInformation("Yandex Music: updated album artists for {Updated} of {Total} tracks", updated, items.Count); _logger.LogInformation("Yandex Music: repaired metadata links for {Updated} tracks", updated);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Version>1.0.0.4</Version> <Version>1.0.0.6</Version>
<AssemblyVersion>1.0.0.4</AssemblyVersion> <AssemblyVersion>1.0.0.6</AssemblyVersion>
<FileVersion>1.0.0.4</FileVersion> <FileVersion>1.0.0.6</FileVersion>
<TargetFramework>net10.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.YandexMusic</RootNamespace> <RootNamespace>Jellyfin.Plugin.YandexMusic</RootNamespace>
<AssemblyName>Jellyfin.Plugin.YandexMusic</AssemblyName> <AssemblyName>Jellyfin.Plugin.YandexMusic</AssemblyName>
@@ -91,6 +91,25 @@ public class YandexMusicSongProvider : IRemoteMetadataProvider<Audio, SongInfo>,
audio.Artists = artistNames; audio.Artists = artistNames;
audio.AlbumArtists = albumArtistNames; audio.AlbumArtists = albumArtistNames;
foreach (var name in artistNames)
{
result.AddPerson(new MediaBrowser.Controller.Entities.PersonInfo
{
Name = name,
Type = Jellyfin.Data.Enums.PersonKind.Artist
});
}
foreach (var name in albumArtistNames)
{
result.AddPerson(new MediaBrowser.Controller.Entities.PersonInfo
{
Name = name,
Type = Jellyfin.Data.Enums.PersonKind.AlbumArtist
});
}
AlbumArtistCache.Set(info.Path, albumArtistNames); AlbumArtistCache.Set(info.Path, albumArtistNames);
audio.Album = config.UseYandexAlbumName audio.Album = config.UseYandexAlbumName
? album?.Title ?? info.Album ? album?.Title ?? info.Album
+1 -1
View File
@@ -1,7 +1,7 @@
--- ---
name: "Yandex Music" name: "Yandex Music"
guid: "f3b9626b-da14-4cbf-8ad1-33b92cfa6656" guid: "f3b9626b-da14-4cbf-8ad1-33b92cfa6656"
version: "1.0.0.4" version: "1.0.0.6"
targetAbi: "12.4.0.0" targetAbi: "12.4.0.0"
framework: "net10.0" framework: "net10.0"
overview: "Metadata for music from Yandex Music." overview: "Metadata for music from Yandex Music."
Binary file not shown.
Binary file not shown.
+5 -5
View File
@@ -9,12 +9,12 @@
"imageUrl": "", "imageUrl": "",
"versions": [ "versions": [
{ {
"version": "1.0.0.4", "version": "1.0.0.6",
"changelog": "Fill AlbumArtists so Jellyfin creates artists and albums; add composers/lyricists and artist genres.", "changelog": "Repair Jellyfin 12 artist and genre links for migrated libraries.",
"targetAbi": "12.4.0.0", "targetAbi": "12.4.0.0",
"sourceUrl": "https://git.midns.ru/1xDed/jellyfin-plugin-yandexmusic/raw/branch/main/dist/Jellyfin.Plugin.YandexMusic_1.0.0.4.zip", "sourceUrl": "https://git.midns.ru/1xDed/jellyfin-plugin-yandexmusic/raw/branch/main/dist/Jellyfin.Plugin.YandexMusic_1.0.0.6.zip",
"checksum": "c17a301daee6980d5b2702a30f793ea5", "checksum": "9f46daf3712f256aafed95e2d13ec642",
"timestamp": "2026-11-27T16:38:01Z" "timestamp": "2026-11-27T16:56:58Z"
} }
] ]
} }
+1 -1
View File
@@ -3,7 +3,7 @@ set -euo pipefail
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
VERSION="1.0.0.4" VERSION="1.0.0.6"
NAME="Jellyfin.Plugin.YandexMusic" NAME="Jellyfin.Plugin.YandexMusic"
PUBLISH_DIR="publish" PUBLISH_DIR="publish"
ARTIFACTS_DIR="${ARTIFACTS_DIR:-artifacts}" ARTIFACTS_DIR="${ARTIFACTS_DIR:-artifacts}"