From 0b5aef5ea93d58972688e70e9545e351ab4b4b12 Mon Sep 17 00:00:00 2001 From: Inrixia Date: Mon, 7 Oct 2024 14:38:20 +1300 Subject: [PATCH] lib.makeTags - Don't use musicbrainz disambiguation. Fixes #83 & general title formatting issues --- plugins/_lib/makeTags.ts | 24 ++++++++----------- .../native/request/helpers.native.ts | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/plugins/_lib/makeTags.ts b/plugins/_lib/makeTags.ts index ffad2937..02790cce 100644 --- a/plugins/_lib/makeTags.ts +++ b/plugins/_lib/makeTags.ts @@ -5,16 +5,8 @@ import { ExtendedMediaItem } from "./Caches/ExtendedTrackItem"; import { Album, TrackItem } from "neptune-types/tidal"; import type { MediaItem } from "./Caches/MediaItemCache"; -const sanitizeDisambiguation = (d?: string | null): string | false => { - if (d === undefined || d === null) 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; -}; - const englishCharRegex = /[a-zA-Z]/; -const hasEnglish = (str?: string) => !!str && /[a-zA-Z]/.test(str); +const hasEnglish = (str?: string) => !!str && englishCharRegex.test(str); export const fullTitle = (tidal?: { title?: string; version?: string }, musicBrainz?: { title?: string; disambiguation?: string }) => { const brainzTitle = musicBrainz?.title; @@ -31,8 +23,9 @@ export const fullTitle = (tidal?: { title?: string; version?: string }, musicBra if (mbMissingFeat || mbInAnotherLanguage) title = tidalTitle; if (title === undefined) return undefined; - const disambiguation = sanitizeDisambiguation(musicBrainz?.disambiguation ?? tidal?.version); - if (disambiguation && !title.includes(disambiguation)) title += ` (${disambiguation})`; + // Dont use musicBrainz disambiguation as its not the same as the tidal version! + const version = tidal?.version; + if (version && !title.includes(version)) title += ` (${version})`; return title; }; @@ -125,8 +118,11 @@ export const makeTags = async (extTrackItem: ExtendedMediaItem): Promise { const OK = res.statusCode !== undefined && res.statusCode >= 200 && res.statusCode < 300; if (!OK) { toJson(res) - .then((body) => libTrace.err(`(${res.statusCode})`, body)) + .then((body) => libTrace.err(`(${res.statusCode})`, body, res.url)) .catch(() => {}); throw new Error(`Status code is ${res.statusCode}`); }