fix(worker): prefer the original release-group over same-titled reissues
The real root cause of "Hybrid Theory" re-downloading forever: MB lists the 2000 original and a 2023 reissue as SEPARATE same-titled Album release-groups. They tie on (artist, title, is_album), so _best_release_group kept whichever MB relevance-ordered first — the 2023 reissue (13 tracks / ~52 min). Its inflated tracklist+runtime then failed the completeness/duration checks against the standard 12-track album sources deliver, looping endlessly. Add an earliest-first-release-date tie-break so the original group wins. (Complements _pick_release, which handles reissue releases *within* a group.) 335 tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,12 @@ def _is_album(g: dict) -> bool:
|
||||
return (g.get("primary-type") or "").casefold() == "album"
|
||||
|
||||
|
||||
def _rg_year(g: dict) -> int:
|
||||
"""First-release year of a release-group, or 9999 when unknown (so undated groups lose ties)."""
|
||||
frd = (g.get("first-release-date") or "")[:4]
|
||||
return int(frd) if frd.isdigit() else 9999
|
||||
|
||||
|
||||
def _credited_artist(g: dict) -> str:
|
||||
"""Primary credited artist name of a release-group search result, or '' if absent."""
|
||||
credit = g.get("artist-credit")
|
||||
@@ -56,7 +62,12 @@ def _best_release_group(artist: str, album: str, groups: list) -> dict | None:
|
||||
* title similarity is next;
|
||||
* an Album primary-type only breaks ties *within* the same artist+title, so a famous
|
||||
album (Michael Jackson's "Off the Wall") still isn't resolved to its same-named
|
||||
single whose short tracklist would map positionally onto the album's files.
|
||||
single whose short tracklist would map positionally onto the album's files;
|
||||
* finally, the EARLIEST release-group wins — MusicBrainz lists the original album and its
|
||||
later reissues/anniversary editions as separate same-titled groups (Linkin Park "Hybrid
|
||||
Theory": a 2000 original and a 2023 13-track reissue), which tie on everything above, so
|
||||
MB's arbitrary relevance order used to pick a reissue whose longer tracklist/runtime then
|
||||
failed completeness checks against the standard album a source delivers. Prefer the original.
|
||||
Artist is a ranking signal, never a hard filter — a low match sinks a candidate but
|
||||
never drops the release, so credited-name variations (feat., punctuation) still resolve.
|
||||
Returns None below the title threshold. Pure — no network I/O."""
|
||||
@@ -68,6 +79,7 @@ def _best_release_group(artist: str, album: str, groups: list) -> dict | None:
|
||||
_ratio(artist, _credited_artist(g)),
|
||||
_ratio(album, g.get("title", "")),
|
||||
_is_album(g),
|
||||
-_rg_year(g), # tie-break: the original (earliest) group over later reissues
|
||||
),
|
||||
)
|
||||
if _ratio(album, best.get("title", "")) < _MIN_TITLE_RATIO:
|
||||
|
||||
Reference in New Issue
Block a user