Skip to content

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

Draft
arsinclair wants to merge 1 commit into
masterfrom
feat/improve-release-type-detection
Draft

feat(common): improve Release Type detection algorithm#953
arsinclair wants to merge 1 commit 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 :)

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