Skip to content

Commit

Permalink
makeTags - Also sanitize disambiguation for #83
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Sep 24, 2024
1 parent 87d795a commit 8b6d91d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plugins/_lib/makeTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import { ExtendedMediaItem } from "./Caches/ExtendedTrackItem";
import { Album, TrackItem } from "neptune-types/tidal";
import type { MediaItem } from "./Caches/MediaItemCache";

const sanitizeDisambiguation = (d?: string): string | false => {
if (d === undefined) return false;
let _d = d.toLowerCase();
if (_d.startsWith("deluxe")) return "Deluxe";
if (_d.includes("explicit") || _d.includes("48khz") || _d.includes("96khz") || _d.includes("24bit") || _d.includes("24-bit") || _d.includes("mastered for itunes")) return false;
return d;
};

export const fullTitle = (tidal?: { title?: string; version?: string }, musicBrainz?: { title?: string; disambiguation?: string }) => {
let title = musicBrainz?.title ?? tidal?.title;

Expand All @@ -13,7 +21,7 @@ export const fullTitle = (tidal?: { title?: string; version?: string }, musicBra

if (title === undefined) return undefined;

const disambiguation = musicBrainz?.disambiguation ?? tidal?.version;
const disambiguation = sanitizeDisambiguation(musicBrainz?.disambiguation ?? tidal?.version);
if (disambiguation && !title.includes(disambiguation)) title += ` (${disambiguation})`;

return title;
Expand Down

0 comments on commit 8b6d91d

Please sign in to comment.