Release 1.0.0.2: fix string track ids and untagged matching
This commit is contained in:
1 parent
3c0a32852c
commit
16515c5166
12 files changed
+80
-26
No files matched your search
@@ -1,9 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>1.0.0.1</Version>
|
||||
<AssemblyVersion>1.0.0.1</AssemblyVersion>
|
||||
<FileVersion>1.0.0.1</FileVersion>
|
||||
<Version>1.0.0.2</Version>
|
||||
<AssemblyVersion>1.0.0.2</AssemblyVersion>
|
||||
<FileVersion>1.0.0.2</FileVersion>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>Jellyfin.Plugin.YandexMusic</RootNamespace>
|
||||
<AssemblyName>Jellyfin.Plugin.YandexMusic</AssemblyName>
|
||||
|
||||
@@ -186,21 +186,38 @@ public static class MatchScoring
|
||||
int toleranceSeconds)
|
||||
{
|
||||
(TrackDto Track, double Score)? best = null;
|
||||
var hasArtists = artists.Any(a => !string.IsNullOrWhiteSpace(a));
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
var titleScore = TextMatch.Similarity(title, track.Title);
|
||||
var artistScore = TextMatch.ArtistSimilarity(
|
||||
artists,
|
||||
track.Artists.Select(a => a.Name));
|
||||
var artistScore = hasArtists
|
||||
? TextMatch.ArtistSimilarity(artists, track.Artists.Select(a => a.Name))
|
||||
: 1;
|
||||
var durationScore = DurationScore(durationMs, track.DurationMs, toleranceSeconds);
|
||||
|
||||
var score = durationScore is null
|
||||
? (0.6 * titleScore) + (0.4 * artistScore)
|
||||
: (0.5 * titleScore) + (0.3 * artistScore) + (0.2 * durationScore.Value);
|
||||
|
||||
if (titleScore < 0.68 || artistScore < 0.42)
|
||||
double score;
|
||||
if (hasArtists)
|
||||
{
|
||||
continue;
|
||||
if (titleScore < 0.68 || artistScore < 0.42)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
score = durationScore is null
|
||||
? (0.6 * titleScore) + (0.4 * artistScore)
|
||||
: (0.5 * titleScore) + (0.3 * artistScore) + (0.2 * durationScore.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No artist tags at all: rely on the title and, when available, the duration.
|
||||
if (titleScore < 0.8)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
score = durationScore is null
|
||||
? titleScore
|
||||
: (0.65 * titleScore) + (0.35 * durationScore.Value);
|
||||
}
|
||||
|
||||
if (best is null || score > best.Value.Score)
|
||||
|
||||
@@ -117,7 +117,9 @@ public class YandexMusicImageProvider : IRemoteImageProvider, IHasOrder
|
||||
}
|
||||
}
|
||||
|
||||
var tracks = await _client.SearchTracksAsync($"{audio.Artists.FirstOrDefault()} {audio.Name}", cancellationToken)
|
||||
var artist = string.Join(" ", audio.Artists.Where(a => !string.IsNullOrWhiteSpace(a))).Trim();
|
||||
var query = string.IsNullOrWhiteSpace(artist) ? audio.Name : $"{artist} {audio.Name}";
|
||||
var tracks = await _client.SearchTracksAsync(query, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
var match = MatchScoring.FindBestTrack(
|
||||
tracks,
|
||||
|
||||
@@ -57,7 +57,10 @@ public class YandexMusicLyricProvider : ILyricProvider, IHasOrder
|
||||
|
||||
if (track is null)
|
||||
{
|
||||
var artist = request.ArtistNames?.FirstOrDefault() ?? request.AlbumArtistsNames?.FirstOrDefault();
|
||||
var artist = string.Join(
|
||||
" ",
|
||||
(request.ArtistNames ?? request.AlbumArtistsNames ?? Array.Empty<string>())
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a))).Trim();
|
||||
var query = string.IsNullOrWhiteSpace(artist)
|
||||
? request.SongName
|
||||
: $"{artist} {request.SongName}";
|
||||
|
||||
@@ -217,7 +217,7 @@ public class YandexMusicSongProvider : IRemoteMetadataProvider<Audio, SongInfo>,
|
||||
private async Task<List<TrackDto>> SearchTracksAsync(SongInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var artists = info.Artists.Count > 0 ? info.Artists : info.AlbumArtists;
|
||||
var artist = artists.FirstOrDefault();
|
||||
var artist = string.Join(" ", artists.Where(a => !string.IsNullOrWhiteSpace(a))).Trim();
|
||||
var query = string.IsNullOrWhiteSpace(artist) ? info.Name : $"{artist} {info.Name}";
|
||||
var tracks = await _client.SearchTracksAsync(query, cancellationToken).ConfigureAwait(false);
|
||||
if (tracks.Count == 0 && !string.IsNullOrWhiteSpace(info.Name))
|
||||
|
||||
@@ -66,6 +66,7 @@ public sealed class CoverDto
|
||||
public sealed class TrackDto
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
[JsonConverter(typeof(FlexibleLongConverter))]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonPropertyName("realId")]
|
||||
|
||||
Reference in new issue
Block a user