Release 1.0.0.3: fix artist wrapper and lyrics fallback

This commit is contained in:
1xDed committed 2026-11-27 19:17:00 +03:00
1 parent 16515c5166
commit 84e3ea34c8
10 files changed
+92 -13

No files matched your search

@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.0.0.2</Version>
<AssemblyVersion>1.0.0.2</AssemblyVersion>
<FileVersion>1.0.0.2</FileVersion>
<Version>1.0.0.3</Version>
<AssemblyVersion>1.0.0.3</AssemblyVersion>
<FileVersion>1.0.0.3</FileVersion>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.YandexMusic</RootNamespace>
<AssemblyName>Jellyfin.Plugin.YandexMusic</AssemblyName>
@@ -164,6 +164,13 @@ public class YandexMusicLyricProvider : ILyricProvider, IHasOrder
}
}
var supplement = await _client.GetSupplementLyricsAsync(trackId, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrWhiteSpace(supplement))
{
Cache[trackId] = (supplement, "txt", DateTime.UtcNow);
return (supplement, "txt");
}
return null;
}
}
@@ -229,6 +229,22 @@ public sealed class ArtistLinkDto
public string? SocialNetwork { get; set; }
}
/// <summary>Response of /artists/{id}.</summary>
public sealed class ArtistDetailResponse
{
[JsonPropertyName("artist")]
public ArtistDto? Artist { get; set; }
[JsonPropertyName("albums")]
public List<AlbumDto> Albums { get; set; } = [];
[JsonPropertyName("similarArtists")]
public List<ArtistDto> SimilarArtists { get; set; } = [];
[JsonPropertyName("allCovers")]
public List<CoverDto> AllCovers { get; set; } = [];
}
/// <summary>Response of /artists/{id}/info.</summary>
public sealed class ArtistInfoResponse
{
@@ -297,6 +313,30 @@ public sealed class GenreTitleDto
public string? FullTitle { get; set; }
}
/// <summary>Track supplement response.</summary>
public sealed class SupplementResponse
{
[JsonPropertyName("result")]
public SupplementDto? Result { get; set; }
}
/// <summary>Track supplement payload.</summary>
public sealed class SupplementDto
{
[JsonPropertyName("lyrics")]
public SupplementLyricsDto? Lyrics { get; set; }
}
/// <summary>Lyrics contained in a track supplement.</summary>
public sealed class SupplementLyricsDto
{
[JsonPropertyName("lyrics")]
public string? Lyrics { get; set; }
[JsonPropertyName("fullLyrics")]
public string? FullLyrics { get; set; }
}
/// <summary>Lyrics lookup response.</summary>
public sealed class LyricsResponse
{
@@ -154,11 +154,11 @@ public sealed class YandexMusicClient
/// <summary>Gets an artist by id.</summary>
public async Task<ArtistDto?> GetArtistAsync(long id, CancellationToken cancellationToken)
{
var response = await GetJsonAsync<YandexResponse<ArtistDto>>(
var response = await GetJsonAsync<YandexResponse<ArtistDetailResponse>>(
string.Format(CultureInfo.InvariantCulture, "/artists/{0}", id),
false,
cancellationToken).ConfigureAwait(false);
return response?.Result;
return response?.Result?.Artist;
}
/// <summary>Gets the extended artist card (bio, covers, links).</summary>
@@ -300,6 +300,31 @@ public sealed class YandexMusicClient
}
}
/// <summary>
/// Gets plain lyrics from the track supplement endpoint. Works even though the signed
/// /lyrics endpoint currently rejects signatures with "Invalid Sign".
/// </summary>
public async Task<string?> GetSupplementLyricsAsync(long trackId, CancellationToken cancellationToken)
{
if (Token is null || !Config.EnableLyrics)
{
return null;
}
var response = await GetJsonAsync<SupplementResponse>(
string.Format(CultureInfo.InvariantCulture, "/tracks/{0}/supplement", trackId),
true,
cancellationToken).ConfigureAwait(false);
var text = response?.Result?.Lyrics?.FullLyrics;
if (string.IsNullOrWhiteSpace(text))
{
text = response?.Result?.Lyrics?.Lyrics;
}
return string.IsNullOrWhiteSpace(text) ? null : text.TrimStart('\uFEFF', '\u200B', ' ', '\r', '\n');
}
/// <summary>Downloads an image from an allowed Yandex host.</summary>
public async Task<byte[]?> GetImageBytesAsync(string url, CancellationToken cancellationToken)
{