Release 1.0.0.2: fix string track ids and untagged matching

This commit is contained in:
1xDed committed 2026-11-27 19:05:05 +03:00
1 parent 3c0a32852c
commit 16515c5166
12 files changed
+80 -26

No files matched your search

@@ -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)