feat: track missing tracks in Navidrome playlist creation notification
Collects tracks not matched in Navidrome search during playlist creation and saves them as 'missing' in the notification — expandable list in the bell panel labeled 'nicht in Navidrome gefunden'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5a26b764d
commit
4ab54e12e1
1 file changed
+10
-1
@@ -314,6 +314,7 @@ async function _createNdPlaylist(tracks, name) {
|
|||||||
try {
|
try {
|
||||||
toast('🎵 Erstelle Navidrome-Playlist…');
|
toast('🎵 Erstelle Navidrome-Playlist…');
|
||||||
const songIds = [];
|
const songIds = [];
|
||||||
|
const missing = [];
|
||||||
const norm = s => s?.toLowerCase().trim() || '';
|
const norm = s => s?.toLowerCase().trim() || '';
|
||||||
for (const t of tracks) {
|
for (const t of tracks) {
|
||||||
if (!t.trackName) continue;
|
if (!t.trackName) continue;
|
||||||
@@ -325,15 +326,19 @@ async function _createNdPlaylist(tracks, name) {
|
|||||||
norm(s.artist).split(' ')[0] === norm(t.artistName).split(' ')[0]
|
norm(s.artist).split(' ')[0] === norm(t.artistName).split(' ')[0]
|
||||||
) || songs.find(s => norm(s.title) === norm(t.trackName));
|
) || songs.find(s => norm(s.title) === norm(t.trackName));
|
||||||
if (match) songIds.push(match.id);
|
if (match) songIds.push(match.id);
|
||||||
} catch {}
|
else missing.push(t.trackName);
|
||||||
|
} catch { missing.push(t.trackName); }
|
||||||
}
|
}
|
||||||
if (!songIds.length) {
|
if (!songIds.length) {
|
||||||
toast('⚠ Keine Tracks in Navidrome gefunden — zuerst Library scannen, dann Playlist manuell anlegen');
|
toast('⚠ Keine Tracks in Navidrome gefunden — zuerst Library scannen, dann Playlist manuell anlegen');
|
||||||
|
_addNotif({ id: 'pl_' + Date.now(), title: `Playlist: ${name}`, artist: '', status: 'error', message: 'Keine Tracks in Navidrome gefunden — Library scan nötig', missing, timestamp: Date.now(), read: false });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const songParams = songIds.map(id => `&songId=${encodeURIComponent(id)}`).join('');
|
const songParams = songIds.map(id => `&songId=${encodeURIComponent(id)}`).join('');
|
||||||
await api('createPlaylist', `&name=${encodeURIComponent(name)}${songParams}`);
|
await api('createPlaylist', `&name=${encodeURIComponent(name)}${songParams}`);
|
||||||
|
const msg = `${songIds.length}/${tracks.length} Tracks hinzugefügt${missing.length ? `, ${missing.length} nicht gefunden` : ''}`;
|
||||||
toast(`✅ Playlist "${name}" mit ${songIds.length}/${tracks.length} Tracks erstellt`);
|
toast(`✅ Playlist "${name}" mit ${songIds.length}/${tracks.length} Tracks erstellt`);
|
||||||
|
_addNotif({ id: 'pl_' + Date.now(), title: `Playlist: ${name}`, artist: '', status: 'done', message: msg, missing, timestamp: Date.now(), read: false });
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
toast('Playlist-Erstellung fehlgeschlagen: ' + e.message);
|
toast('Playlist-Erstellung fehlgeschlagen: ' + e.message);
|
||||||
}
|
}
|
||||||
@@ -408,6 +413,9 @@ function _renderNotifList() {
|
|||||||
const failedHtml = n.failed?.length
|
const failedHtml = n.failed?.length
|
||||||
? `<details class="notif-failed"><summary>${n.failed.length} Track${n.failed.length > 1 ? 's' : ''} fehlgeschlagen</summary><ul>${n.failed.map(f => `<li>${esc(f)}</li>`).join('')}</ul></details>`
|
? `<details class="notif-failed"><summary>${n.failed.length} Track${n.failed.length > 1 ? 's' : ''} fehlgeschlagen</summary><ul>${n.failed.map(f => `<li>${esc(f)}</li>`).join('')}</ul></details>`
|
||||||
: '';
|
: '';
|
||||||
|
const missingHtml = n.missing?.length
|
||||||
|
? `<details class="notif-failed"><summary>${n.missing.length} Track${n.missing.length > 1 ? 's' : ''} nicht in Navidrome gefunden</summary><ul>${n.missing.map(f => `<li>${esc(f)}</li>`).join('')}</ul></details>`
|
||||||
|
: '';
|
||||||
return `<div class="notif-card${n.read ? '' : ' unread'}">
|
return `<div class="notif-card${n.read ? '' : ' unread'}">
|
||||||
<div class="notif-card-top">
|
<div class="notif-card-top">
|
||||||
<span class="notif-icon">${icon}</span>
|
<span class="notif-icon">${icon}</span>
|
||||||
@@ -419,6 +427,7 @@ function _renderNotifList() {
|
|||||||
</div>
|
</div>
|
||||||
${n.message ? `<div class="notif-msg">${esc(n.message)}</div>` : ''}
|
${n.message ? `<div class="notif-msg">${esc(n.message)}</div>` : ''}
|
||||||
${failedHtml}
|
${failedHtml}
|
||||||
|
${missingHtml}
|
||||||
</div>`;
|
</div>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user