- `).join('');
+ tbody.innerHTML = data.playlists.map(p => {
+ // For now, we don't have local/external counts in the API response
+ // This will show "-" until we add that data
+ const localExternal = (p.localTracks !== undefined && p.externalTracks !== undefined)
+ ? `${p.localTracks}/${p.externalTracks}`
+ : '-';
+
+ return `
+
+
${escapeHtml(p.name)}
+
${p.id || '-'}
+
${p.trackCount || 0}
+
${localExternal}
+
${p.cacheAge || '-'}
+
+
+
+
+
+
+ `;
+ }).join('');
} catch (error) {
console.error('Failed to fetch playlists:', error);
showToast('Failed to fetch playlists', 'error');
@@ -1321,6 +1332,22 @@
}
}
+ async function matchPlaylistTracks(name) {
+ try {
+ showToast(`Matching tracks for ${name}...`, 'success');
+ const res = await fetch(`/api/admin/playlists/${encodeURIComponent(name)}/match`, { method: 'POST' });
+ const data = await res.json();
+
+ if (res.ok) {
+ showToast(data.message, 'success');
+ } else {
+ showToast(data.error || 'Failed to match tracks', 'error');
+ }
+ } catch (error) {
+ showToast('Failed to match tracks', 'error');
+ }
+ }
+
async function clearCache() {
if (!confirm('Clear all cached playlist data?')) return;