[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: Make artist name to credit function more robust

* artistNameToCredit can now handle partial ArtistCredit object
* Re-use artistNameToCredit for mapping in artistNameToCredits

FoxxMD (May 28, 2026, 3:07 PM UTC) 1eed4845 20834e81

+21 -2
+21 -2
src/core/StringUtils.ts
··· 16 16 } from "./Atomic.js"; 17 17 import { DELIMETERS_REGEX, DELIMITERS } from "../backend/common/infrastructure/Atomic.js"; 18 18 import { parseRegexSingle } from "@foxxmd/regex-buddy-core"; 19 + import { removeUndefinedKeys } from "../backend/utils.js"; 19 20 20 21 dayjs.extend(utc) 21 22 dayjs.extend(isBetween); ··· 309 310 const NUMBERS_REGEX = new RegExp(/^\s*\d+\s*$/); 310 311 export const stringIsOnlyNumbers = (str: string) => NUMBERS_REGEX.test(str); 311 312 312 - export const artistNamesToCredits = (names: string[] | undefined): ArtistCredit[] => names === undefined ? undefined : names.map((x) => ({name: x})); 313 - export const artistNameToCredit = (name: string | undefined): ArtistCredit => name === undefined ? undefined : ({ name }); 313 + export const artistNamesToCredits = (names: (string | Partial<ArtistCredit>)[] | undefined): ArtistCredit[] => { 314 + if(names === undefined) { 315 + return undefined; 316 + } 317 + return names.map(artistNameToCredit).filter(x => x !== undefined); 318 + }; 319 + export const artistNameToCredit = (val: string | undefined | Partial<ArtistCredit>): ArtistCredit => { 320 + if(val === undefined) { 321 + return undefined; 322 + } 323 + if(typeof val === 'string') { 324 + return {name: val}; 325 + } 326 + const { 327 + name, 328 + mbid, 329 + ...rest 330 + } = val; 331 + return removeUndefinedKeys({name, mbid, ...rest}); 332 + } 314 333 export const artistCreditToName = (a: ArtistCredit): string => a.name; 315 334 export const artistCreditsToNames = (a: ArtistCredit[]): string[] => a.map((x) => x.name);