Skip to content

Commit e8a713c

Browse files
authored
perf: Use limited pattern for live track title checks
Splits out pattern for detection of live tracks and uses it instead of using `guessTypesFromTitle` which checks titles against other formats meant for the release title. This should also be better for performance since additional/unnecessary pattern matching is avoided.
1 parent b9818f3 commit e8a713c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

harmonizer/release_types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,16 @@ export function guessTypesFromTitle(title: string): Set<ReleaseGroupType> {
7272
return types;
7373
}
7474

75+
/**
76+
* Expression matching common live track name patterns.
77+
* Both `Track name - Live` and `Track name (Live)`.
78+
*/
79+
const liveTrackPattern = /\s(?:- Live|\(Live\))(?:\s\(.*?\))?$/i;
80+
7581
/** Returns true if all track titles indicate a live release. */
7682
export function guessLiveRelease(tracks: HarmonyTrack[]): boolean {
7783
return tracks?.length > 0 && tracks.every((track) => {
78-
const types = guessTypesFromTitle(track.title);
79-
return types.has('Live');
84+
return liveTrackPattern.test(track.title);
8085
});
8186
}
8287

0 commit comments

Comments
 (0)