feat(common): improve Release Type detection algorithm - #953
Conversation
|
Looks good to me. But AI points out a possible bug
The 2-track fallback bugTake a look at the sequential logic in the } else {
// no duration, try to guess by the number of tracks only.
if (perhaps_EP) return "EP";
if (perhaps_single) return "single";
if (perhaps_album) return "album";
}Because In practice, a 2-track release—usually an A-side/B-side pair, an instrumental, or a remix bundle—is almost always a Single. Checking the EP threshold first causes immediate misclassifications here. The fix: Reorder the sequence so the logic catches 1- or 2-track releases as a single before checking the EP threshold. A different way to handle thisFor some context on how to make this even more reliable, look at how Instead of looking at duration, it strips common technical terms from the track titles (things like Remix, Instrumental, Edit, Live, or Version) and compares what is left. If a multi-track release deduplicates down to a single unique title, the script overrides the status to a Single because it knows the release just contains alternate versions of the same song. Relying strictly on track numbers and durations is always going to hit edge cases—especially with modern streaming singles that often bundle 3 or 4 tracks. Implementing a title-deduplication check like that would be a great way to make this guesser bulletproof. |
This is often the case for Vinyl records, but not always true, especially for a bunch of electronic genres. It we reorder the sequence, then EP branch will never trigger for releases without duration, since Single branch with 1..6 tracks will include the 2..6-track branch for EP. Additionally the set EP vs. Single sets intersection for releases with a present duration will change in ways that I cannot really see clearly.
I suppose this is a great idea. I will try to add it in the next iteration. But I don't think it should completely replace the type-guesser based on the track numbers/durations, because then we will be left with quite a large number of releases which could be easily classified based on those parameters. Instead, I think we should first try to normalise song names and deduce if it's a Single, and if it yields no results then fall back on the current algo. Let me know your thoughts. |
I'm aware of that. I added quite a lot of techno stuff where EPs are common for 2-track releases. Regarding the Harmony Enhancements script, Harmony doesn't do much release type guessing instead relying on the providers, which also classify based on track count and duration.
Agree, such singles are easy to detect and rarely not a single per artist/label. If the release title contains EP it should still take precedence. |
|
BTW some unit tests could probably be added for verifying the expected behavior :) |
Before: - The EP branch shadowed the Single branch for almost every 2–6-track release. - Two-track releases without durations were always classified as EPs. - The no-duration logic was unreachable from normal imports. - `NaN` checks incorrectly accepted infinities and zero/negative durations. - Explicit EP/Single conflicts discarded both signals. - No track-title deduplication was implemented. After: - Added normalized track-title comparison for remix, edit, instrumental, live, version, mix, dub, and similar qualifiers. - Large remix bundles can now be classified as Singles before album heuristics. - Explicit EP takes precedence, as agreed in the discussion. - Ambiguous two-track releases without durations remain unclassified. - Restored coherent duration boundaries and 7+ track album handling. - Enabled guessing when durations are incomplete. - Added tests
|
Hey, I made changes to hopefully address all remaining problems. Single heuristics also implemented and tests added. @chaban-mb could you also review please and give it a go? |
I can't give you a code review but I can test it. It works for the example from earlier. I'll try to test it some more. |
|
Thanks. I'm going to inject this change into my local userscript first and run it like that for a week/two. If you don't find any issues and I am happy with how it works, then I'll merge this. |
Uh oh!
There was an error while loading. Please reload this page.