refactor: make adapter .tier the single source of truth for ranking

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-10 19:07:58 +02:00
parent fbd6a056a4
commit d3bec2ee10
6 changed files with 14 additions and 19 deletions
+4 -1
View File
@@ -6,11 +6,14 @@ CD = Quality(fmt="FLAC", lossless=True, bit_depth=16, sample_rate=44100)
MP3 = Quality(fmt="MP3", lossless=False, bitrate_kbps=320)
TARGET = MBTarget(artist="Radiohead", album="In Rainbows", track_count=10)
_TIERS = {"qobuz": 0, "soulseek": 1, "youtube": 2}
def _cand(source, quality, artist="Radiohead", album="In Rainbows", tracks=10):
return Candidate(source=source, source_ref=f"{source}:{quality.fmt}",
matched_artist=artist, matched_album=album,
quality=quality, track_count=tracks)
quality=quality, track_count=tracks,
source_tier=_TIERS[source])
def test_returns_empty_for_no_candidates():