From 0a2736e893fa47be5b6de179991781381d29e86f Mon Sep 17 00:00:00 2001 From: Honey Date: Thu, 4 Jun 2026 20:33:49 +0200 Subject: [PATCH] fix: build error in nextSong + apply romaji overrides to downloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix missing closing brace for `if (ni >= 0...)` in nextSong — the removed `else { _nsBridge('next') }` left the inner if-block unclosed, causing vite/rollup to reject player.js as invalid JS - Apply romaji override map to iTunes (executeDownload) and Spotify (executeSpotifyDownload) download payloads — sends artistSort/albumArtistSort/ titleSort/albumSort fields so the backend writes correct sort tags to the downloaded file and can organize into the right artist folder Co-Authored-By: Claude Sonnet 4.6 --- src/player.js | 1 + src/ui.js | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/player.js b/src/player.js index 0b19a69..7ef5522 100644 --- a/src/player.js +++ b/src/player.js @@ -716,6 +716,7 @@ export function nextSong() { // Explicit index prevents desync when JS and native queue pointers diverge. _nsBridge('seekToIndex', ni, 0); _nsBridge('play'); + } // else: ni = -1 means end of queue with no repeat — let ExoPlayer stop naturally. if (S.radioMode && S.queue.length - S.qIdx < 5) fillRadioQueue(); return; diff --git a/src/ui.js b/src/ui.js index 96da557..2d6bb16 100644 --- a/src/ui.js +++ b/src/ui.js @@ -610,11 +610,15 @@ export async function executeDownload() { if(!S.downloadTarget || !S.cfg.backendUrl) return; closeDlModal(); const jobId = 'job_' + Date.now(); + const ov = getRomajiOverrides(); + const _artist = S.downloadTarget.artistName || 'Unknown Artist'; + const _title = S.downloadTarget.trackName || S.downloadTarget.collectionName || 'Unknown'; + const _album = S.downloadTarget.collectionName || ''; const payload = { type: S.dlType, - artist: S.downloadTarget.artistName || 'Unknown Artist', - title: S.downloadTarget.trackName || S.downloadTarget.collectionName || 'Unknown', - album: S.downloadTarget.collectionName || '', + artist: _artist, + title: _title, + album: _album, artworkUrl: S.downloadTarget.artworkUrl100 || S.downloadTarget.artworkUrl60 || '', itunesId: S.downloadTarget.trackId || S.downloadTarget.collectionId || null, collectionId: S.downloadTarget.collectionId || null, @@ -624,6 +628,9 @@ export async function executeDownload() { discNum: S.downloadTarget.discNumber || undefined, discTotal: S.downloadTarget.discCount || undefined, durationMs: S.downloadTarget.trackTimeMillis || undefined, + ...(ov[_artist] && { artistSort: ov[_artist], albumArtistSort: ov[_artist] }), + ...(ov[_title] && { titleSort: ov[_title] }), + ...(ov[_album] && { albumSort: ov[_album] }), }; addJob(jobId, payload.title, payload.artist, payload.type, payload.album); try { @@ -644,11 +651,23 @@ export async function executeSpotifyDownload({ type, title, artist, artworkUrl, if (!S.cfg.backendUrl) { toast('⚠ Kein Backend konfiguriert'); return; } const jobId = 'job_' + Date.now(); addJob(jobId, title, artist, type); + const ov = getRomajiOverrides(); + const enrichedTracks = (tracks || []).map(t => { + const a = t.artistName || ''; + const n = t.trackName || ''; + const al = t.collectionName || ''; + return { + ...t, + ...(ov[a] && { artistSort: ov[a], albumArtistSort: ov[a] }), + ...(ov[n] && { titleSort: ov[n] }), + ...(ov[al] && { albumSort: ov[al] }), + }; + }); try { const res = await fetch(`${S.cfg.backendUrl}/api/download`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ jobId, type, title, artist, artworkUrl, tracks }), + body: JSON.stringify({ jobId, type, title, artist, artworkUrl, tracks: enrichedTracks }), }); if (!res.ok) throw new Error(`HTTP ${res.status}`); pollJob(jobId);