Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5674bec6a |
No files matched your search
@@ -1,39 +1,43 @@
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Plugin.YandexMusic.Providers;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.YandexMusic;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// Repairs music metadata links after a Jellyfin 10 -> 12 migration:
|
||||
/// fills AlbumArtists, writes Artists/Genres into the new item-value tables and creates person links.
|
||||
/// </summary>
|
||||
public class AlbumArtistTask : IScheduledTask
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IDtoService _dtoService;
|
||||
private readonly ILogger<AlbumArtistTask> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AlbumArtistTask"/> class.
|
||||
/// </summary>
|
||||
public AlbumArtistTask(ILibraryManager libraryManager, ILogger<AlbumArtistTask> logger)
|
||||
public AlbumArtistTask(ILibraryManager libraryManager, IDtoService dtoService, ILogger<AlbumArtistTask> logger)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_dtoService = dtoService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Yandex Music: создать исполнителей";
|
||||
public string Name => "Yandex Music: исправить исполнителей и жанры";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Key => "YandexMusicAlbumArtists";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Description => "Заполняет AlbumArtists и связи исполнителей, чтобы Jellyfin создал страницы исполнителей.";
|
||||
public string Description => "Переносит исполнителей, альбомных исполнителей и жанры в новую модель Jellyfin 12 и создаёт связи артистов.";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Category => "Yandex Music";
|
||||
@@ -48,50 +52,63 @@ public class AlbumArtistTask : IScheduledTask
|
||||
IsVirtualItem = false
|
||||
}).OfType<Audio>().ToList();
|
||||
|
||||
var dtoOptions = new DtoOptions(true);
|
||||
var updated = 0;
|
||||
for (var i = 0; i < items.Count; i++)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
var item = items[i];
|
||||
|
||||
string[] artists;
|
||||
if (AlbumArtistCache.TryGet(item.Path, out var cached))
|
||||
var dto = _dtoService.GetBaseItemDto(item, dtoOptions);
|
||||
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)
|
||||
{
|
||||
artists = [item.Artists[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
artists = [];
|
||||
item.AlbumArtists = [item.Artists[0]];
|
||||
}
|
||||
|
||||
if (artists.Length > 0 && !item.AlbumArtists.SequenceEqual(artists, StringComparer.OrdinalIgnoreCase))
|
||||
if (dtoGenres.Length > 0)
|
||||
{
|
||||
item.AlbumArtists = artists;
|
||||
await item.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
|
||||
updated++;
|
||||
item.Genres = dtoGenres;
|
||||
}
|
||||
|
||||
var people = new List<MediaBrowser.Controller.Entities.PersonInfo>();
|
||||
await item.UpdateToRepositoryAsync(ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var people = new List<PersonInfo>();
|
||||
foreach (var name in item.AlbumArtists)
|
||||
{
|
||||
people.Add(new MediaBrowser.Controller.Entities.PersonInfo
|
||||
{
|
||||
Name = name,
|
||||
Type = Jellyfin.Data.Enums.PersonKind.AlbumArtist
|
||||
});
|
||||
people.Add(new PersonInfo { Name = name, Type = PersonKind.AlbumArtist });
|
||||
}
|
||||
|
||||
foreach (var name in item.Artists)
|
||||
{
|
||||
people.Add(new MediaBrowser.Controller.Entities.PersonInfo
|
||||
{
|
||||
Name = name,
|
||||
Type = Jellyfin.Data.Enums.PersonKind.Artist
|
||||
});
|
||||
people.Add(new PersonInfo { Name = name, Type = PersonKind.Artist });
|
||||
}
|
||||
|
||||
if (people.Count > 0)
|
||||
@@ -99,10 +116,11 @@ public class AlbumArtistTask : IScheduledTask
|
||||
await _libraryManager.UpdatePeopleAsync(item, people, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
updated++;
|
||||
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 />
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>1.0.0.5</Version>
|
||||
<AssemblyVersion>1.0.0.5</AssemblyVersion>
|
||||
<FileVersion>1.0.0.5</FileVersion>
|
||||
<Version>1.0.0.6</Version>
|
||||
<AssemblyVersion>1.0.0.6</AssemblyVersion>
|
||||
<FileVersion>1.0.0.6</FileVersion>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>Jellyfin.Plugin.YandexMusic</RootNamespace>
|
||||
<AssemblyName>Jellyfin.Plugin.YandexMusic</AssemblyName>
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: "Yandex Music"
|
||||
guid: "f3b9626b-da14-4cbf-8ad1-33b92cfa6656"
|
||||
version: "1.0.0.5"
|
||||
version: "1.0.0.6"
|
||||
targetAbi: "12.4.0.0"
|
||||
framework: "net10.0"
|
||||
overview: "Metadata for music from Yandex Music."
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
+5
-5
@@ -9,12 +9,12 @@
|
||||
"imageUrl": "",
|
||||
"versions": [
|
||||
{
|
||||
"version": "1.0.0.5",
|
||||
"changelog": "Add artist people links so the Artists tab works; maintenance task fills them for existing tracks.",
|
||||
"version": "1.0.0.6",
|
||||
"changelog": "Repair Jellyfin 12 artist and genre links for migrated libraries.",
|
||||
"targetAbi": "12.4.0.0",
|
||||
"sourceUrl": "https://git.midns.ru/1xDed/jellyfin-plugin-yandexmusic/raw/branch/main/dist/Jellyfin.Plugin.YandexMusic_1.0.0.5.zip",
|
||||
"checksum": "3fa4bff9075e7e074991e8f47af9c26c",
|
||||
"timestamp": "2026-11-27T16:53:03Z"
|
||||
"sourceUrl": "https://git.midns.ru/1xDed/jellyfin-plugin-yandexmusic/raw/branch/main/dist/Jellyfin.Plugin.YandexMusic_1.0.0.6.zip",
|
||||
"checksum": "9f46daf3712f256aafed95e2d13ec642",
|
||||
"timestamp": "2026-11-27T16:56:58Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
VERSION="1.0.0.5"
|
||||
VERSION="1.0.0.6"
|
||||
NAME="Jellyfin.Plugin.YandexMusic"
|
||||
PUBLISH_DIR="publish"
|
||||
ARTIFACTS_DIR="${ARTIFACTS_DIR:-artifacts}"
|
||||
|
||||
Reference in new issue
Block a user