mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
fix: remove score filtering, add combined title+artist matching
This commit is contained in:
@@ -178,22 +178,19 @@ public class JellyfinController : ControllerBase
|
|||||||
var scoredExternalAlbums = ScoreSearchResults(cleanQuery, externalResult.Albums, a => a.Title, a => a.Artist, isExternal: true);
|
var scoredExternalAlbums = ScoreSearchResults(cleanQuery, externalResult.Albums, a => a.Title, a => a.Artist, isExternal: true);
|
||||||
var scoredExternalArtists = ScoreSearchResults(cleanQuery, externalResult.Artists, a => a.Name, _ => null, isExternal: true);
|
var scoredExternalArtists = ScoreSearchResults(cleanQuery, externalResult.Artists, a => a.Name, _ => null, isExternal: true);
|
||||||
|
|
||||||
// Merge and sort by score (only include items with score >= 40)
|
// Merge and sort by score (no filtering - just reorder by relevance)
|
||||||
var allSongs = scoredLocalSongs.Concat(scoredExternalSongs)
|
var allSongs = scoredLocalSongs.Concat(scoredExternalSongs)
|
||||||
.Where(x => x.Score >= 40)
|
|
||||||
.OrderByDescending(x => x.Score)
|
.OrderByDescending(x => x.Score)
|
||||||
.Select(x => x.Item)
|
.Select(x => x.Item)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var allAlbums = scoredLocalAlbums.Concat(scoredExternalAlbums)
|
var allAlbums = scoredLocalAlbums.Concat(scoredExternalAlbums)
|
||||||
.Where(x => x.Score >= 40)
|
|
||||||
.OrderByDescending(x => x.Score)
|
.OrderByDescending(x => x.Score)
|
||||||
.Select(x => x.Item)
|
.Select(x => x.Item)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Dedupe artists by name, keeping highest scored version
|
// Dedupe artists by name, keeping highest scored version
|
||||||
var artistScores = scoredLocalArtists.Concat(scoredExternalArtists)
|
var artistScores = scoredLocalArtists.Concat(scoredExternalArtists)
|
||||||
.Where(x => x.Score >= 40)
|
|
||||||
.GroupBy(x => x.Item.Name, StringComparer.OrdinalIgnoreCase)
|
.GroupBy(x => x.Item.Name, StringComparer.OrdinalIgnoreCase)
|
||||||
.Select(g => g.OrderByDescending(x => x.Score).First())
|
.Select(g => g.OrderByDescending(x => x.Score).First())
|
||||||
.OrderByDescending(x => x.Score)
|
.OrderByDescending(x => x.Score)
|
||||||
@@ -210,7 +207,6 @@ public class JellyfinController : ControllerBase
|
|||||||
{
|
{
|
||||||
var scoredPlaylists = playlistResult
|
var scoredPlaylists = playlistResult
|
||||||
.Select(p => new { Playlist = p, Score = FuzzyMatcher.CalculateSimilarity(cleanQuery, p.Name) })
|
.Select(p => new { Playlist = p, Score = FuzzyMatcher.CalculateSimilarity(cleanQuery, p.Name) })
|
||||||
.Where(x => x.Score >= 40)
|
|
||||||
.OrderByDescending(x => x.Score)
|
.OrderByDescending(x => x.Score)
|
||||||
.Select(x => _responseBuilder.ConvertPlaylistToJellyfinItem(x.Playlist))
|
.Select(x => _responseBuilder.ConvertPlaylistToJellyfinItem(x.Playlist))
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -1795,11 +1791,21 @@ public class JellyfinController : ControllerBase
|
|||||||
? 0
|
? 0
|
||||||
: FuzzyMatcher.CalculateSimilarity(query, secondary);
|
: FuzzyMatcher.CalculateSimilarity(query, secondary);
|
||||||
|
|
||||||
// Use the better of the two scores
|
// Score against combined "title artist" and "artist title" for queries like "say why zach bryan"
|
||||||
var baseScore = Math.Max(primaryScore, secondaryScore);
|
var combinedScore = 0;
|
||||||
|
if (!string.IsNullOrEmpty(secondary))
|
||||||
|
{
|
||||||
|
var combined1 = $"{primary} {secondary}";
|
||||||
|
var combined2 = $"{secondary} {primary}";
|
||||||
|
var score1 = FuzzyMatcher.CalculateSimilarity(query, combined1);
|
||||||
|
var score2 = FuzzyMatcher.CalculateSimilarity(query, combined2);
|
||||||
|
combinedScore = Math.Max(score1, score2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the best score from all attempts
|
||||||
|
var baseScore = Math.Max(Math.Max(primaryScore, secondaryScore), combinedScore);
|
||||||
|
|
||||||
// Give external results a small boost (+5 points) to prioritize the larger catalog
|
// Give external results a small boost (+5 points) to prioritize the larger catalog
|
||||||
// This means external results will rank slightly higher when scores are close
|
|
||||||
var finalScore = isExternal ? Math.Min(100, baseScore + 5) : baseScore;
|
var finalScore = isExternal ? Math.Min(100, baseScore + 5) : baseScore;
|
||||||
|
|
||||||
return (item, finalScore);
|
return (item, finalScore);
|
||||||
|
|||||||
Reference in New Issue
Block a user