Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Suno import: read excluded styles kept beside the song's metadata
Claudef76af9ea5e9f
diff --git a/server/lib/sunoSong.js b/server/lib/sunoSong.jsindex 2f71cab7e3..b1a55a6c4e 100644--- a/server/lib/sunoSong.js+++ b/server/lib/sunoSong.js@@ -160,16 +160,18 @@ export function parseSunoSongPage(html, songId) {const ref = /^\$([0-9a-f]+)$/i.exec(value)?.[1];return (ref ? texts.get(ref.toLowerCase()) ?? '' : value).trim();};+ // Suno files the excluded styles under `metadata`; read them beside it too.+ const negativeTags = [song.metadata?.negative_tags, song.negative_tags].find((v) => typeof v === 'string');const title = text(song.title) || metaContent(page, 'og:title').replace(/\s*\|\s*Suno\s*$/i, '').trim();const audioUrl = [song.audio_url, metaContent(page, 'og:audio')].find(isSunoCdnUrl) || null;const imageUrl = [song.image_large_url, song.image_url, metaContent(page, 'og:image')].find(isSunoUrl) || null;return {title,lyrics: text(song.metadata?.prompt),- style: withExcludedStyles(text(song.metadata?.tags), text(song.metadata?.negative_tags)),+ style: withExcludedStyles(text(song.metadata?.tags), text(negativeTags)),// Whether the page said anything about excluded styles. An anonymous page// can leave the field out, which is not the same as a song excluding none.- excludedStylesKnown: typeof song.metadata?.negative_tags === 'string',+ excludedStylesKnown: typeof negativeTags === 'string',audioUrl,imageUrl,};diff --git a/server/lib/sunoSong.test.js b/server/lib/sunoSong.test.jsindex b1b65178b6..30fcb6bb00 100644--- a/server/lib/sunoSong.test.js+++ b/server/lib/sunoSong.test.js@@ -59,6 +59,12 @@ describe('parseSunoSongPage', () => {expect(parseSunoSongPage(html, ID)).toMatchObject({ style: 'synth-pop, \u2011bubblegum pop, -metal', excludedStylesKnown: true });});+ it('reads excluded styles kept beside the metadata, as Suno lists them without minus signs', () => {+ const record = { id: ID, title: 'Full', negative_tags: 'metal, cutesy', metadata: { prompt: 'words', tags: 'synth-pop' } };+ const html = page([`4:${JSON.stringify({ song: record })}\n`]);+ expect(parseSunoSongPage(html, ID)).toMatchObject({ style: 'synth-pop, -metal, -cutesy', excludedStylesKnown: true });+ });+it('prefers the full record over a slimmer listing of the same song', () => {const html = page([`4:${JSON.stringify({ playbar: { id: ID, title: 'Short' }, song: { id: ID, title: 'Full', metadata: { prompt: 'words', tags: 'rock' } } })}\n`]);expect(parseSunoSongPage(html, ID)).toMatchObject({ title: 'Full', lyrics: 'words', style: 'rock' });