Skip to content

feat(common): improve Release Type detection algorithm - #953

Open
arsinclair wants to merge 4 commits into
masterfrom
feat/improve-release-type-detection
Open

feat(common): improve Release Type detection algorithm#953
arsinclair wants to merge 4 commits into
masterfrom
feat/improve-release-type-detection

Conversation

@arsinclair

@arsinclair arsinclair commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

@chaban-mb

Copy link
Copy Markdown
Contributor

Looks good to me.

But AI points out a possible bug

The 2-track fallback bug

Take a look at the sequential logic in the else branch:

} 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 perhaps_EP triggers for any track count between 2 and 6, a standard 2-track release with missing durations will always hit that first if and return "EP".

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 this

For some context on how to make this even more reliable, look at how Harmony Enhancements.user.js handles multi-track singles. It completely skips the reliance on arbitrary time brackets or track counts.

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.

@arsinclair

Copy link
Copy Markdown
Collaborator Author

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.

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.

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.

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.

@chaban-mb

Copy link
Copy Markdown
Contributor

This is often the case for Vinyl records, but not always true, especially for a bunch of electronic genres.

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.

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.

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.

@murdos

murdos commented Jun 27, 2026

Copy link
Copy Markdown
Owner

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
@arsinclair
arsinclair requested a review from murdos August 24, 2026 03:30
@arsinclair

Copy link
Copy Markdown
Collaborator Author

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?

@arsinclair
arsinclair marked this pull request as ready for review August 24, 2026 03:31
@chaban-mb

Copy link
Copy Markdown
Contributor

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

@arsinclair

arsinclair commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants