+ // Per-source search panel (hidden, populated on Fix/Match click)
+ html += `
`;
content.innerHTML = html;
-
- // Wire up Change button
- document.getElementById('watchlist-linked-change-btn').onclick = () => {
- document.getElementById('watchlist-linked-search').style.display = '';
- const input = document.getElementById('watchlist-linked-search-input');
- input.focus();
- input.select();
- };
-
- // Wire up search
- const doSearch = () => _searchLinkedProviderArtists(artistId, artistName);
- document.getElementById('watchlist-linked-search-go').onclick = doSearch;
- document.getElementById('watchlist-linked-search-input').onkeydown = (e) => {
- if (e.key === 'Enter') doSearch();
- };
}
/**
- * Search for artists to link to a watchlist entry.
+ * Open per-source search panel for fixing a specific provider match.
*/
-async function _searchLinkedProviderArtists(currentArtistId, watchlistName) {
- const input = document.getElementById('watchlist-linked-search-input');
- const resultsContainer = document.getElementById('watchlist-linked-search-results');
- const query = input?.value?.trim();
- if (!query || !resultsContainer) return;
+function _openSourceSearch(sourceKey, artistId, artistName) {
+ const panel = document.getElementById('wl-linked-search-panel');
+ if (!panel) return;
+ const labels = { spotify: 'Spotify', itunes: 'Apple Music', deezer: 'Deezer', discogs: 'Discogs' };
+ document.getElementById('wl-linked-search-title').textContent = `Search ${labels[sourceKey] || sourceKey}`;
+ const input = document.getElementById('wl-linked-search-input');
+ input.value = artistName;
+ document.getElementById('wl-linked-search-results').innerHTML = '';
+ panel.style.display = '';
+ panel.dataset.source = sourceKey;
+ panel.dataset.artistId = artistId;
+ panel.dataset.artistName = artistName;
+ input.focus();
+ input.select();
- resultsContainer.innerHTML = '
Searching...
';
+ const doSearch = () => _searchSourceArtists(sourceKey, artistId);
+ document.getElementById('wl-linked-search-go').onclick = doSearch;
+ input.onkeydown = (e) => { if (e.key === 'Enter') doSearch(); };
+}
+
+async function _searchSourceArtists(sourceKey, watchlistArtistId) {
+ const input = document.getElementById('wl-linked-search-input');
+ const container = document.getElementById('wl-linked-search-results');
+ const query = input?.value?.trim();
+ if (!query || !container) return;
+
+ container.innerHTML = '
Searching...
';
try {
- // Use match/search to find artists (returns genres, popularity, image)
- const response = await fetch('/api/match/search', {
+ const response = await fetch('/api/library/search-service', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ query: query, context: 'artist' })
+ body: JSON.stringify({ service: sourceKey, entity_type: 'artist', query })
});
const data = await response.json();
+ if (!data.success) throw new Error(data.error);
const results = data.results || [];
- if (results.length === 0) {
- resultsContainer.innerHTML = '
';
return;
}
let html = '';
- for (const r of results.slice(0, 8)) {
- const a = r.artist || r;
- const img = a.image_url || '';
- const genres = (a.genres || []).slice(0, 2).join(', ');
- const pop = a.popularity || 0;
- const followers = a.followers || 0;
- const popMeta = pop > 0 ? `Pop: ${pop}` : followers > 0 ? `${followers.toLocaleString()} fans` : '';
- html += `
- ${img ? `
` :
+ for (const r of results) {
+ html += `
+ ${r.image ? `
` :
`
๐ต
`}
-
${escapeHtml(a.name)}
-
${genres ? escapeHtml(genres) : ''}${genres && popMeta ? ' ยท ' : ''}${popMeta}
+
${escapeHtml(r.name)}
+
${escapeHtml(r.extra || '')}
Select
`;
}
+ container.innerHTML = html;
- resultsContainer.innerHTML = html;
-
- // Wire up select buttons
- resultsContainer.querySelectorAll('.watchlist-linked-search-result').forEach(el => {
+ container.querySelectorAll('.watchlist-linked-search-result').forEach(el => {
el.querySelector('.watchlist-linked-select-btn').onclick = async (e) => {
e.stopPropagation();
- const newId = el.dataset.id;
- const newName = el.dataset.name;
- await _linkProviderArtist(currentArtistId, newId, newName);
+ await _linkSourceArtist(sourceKey, watchlistArtistId, el.dataset.id, el.dataset.name);
};
});
-
} catch (err) {
- console.error('Error searching for linked artist:', err);
- resultsContainer.innerHTML = '
Search error
';
+ console.error(`Error searching ${sourceKey}:`, err);
+ container.innerHTML = '
Search error
';
}
}
-/**
- * Link a watchlist artist to a new provider artist.
- */
-async function _linkProviderArtist(currentArtistId, newProviderId, newProviderName) {
- // Determine provider from active metadata source
- // Spotify IDs are alphanumeric (e.g. "4Z8W4fKeB5YxbusRsdQVPb"), iTunes/Deezer are numeric
- let provider;
- if (/^\d+$/.test(newProviderId)) {
- // Numeric ID โ check configured fallback source to distinguish iTunes from Deezer
- const fallbackSrc = document.getElementById('metadata-fallback-source')?.value || 'itunes';
- provider = fallbackSrc === 'deezer' ? 'deezer' : 'itunes';
- } else {
- provider = 'spotify';
- }
-
+async function _linkSourceArtist(sourceKey, watchlistArtistId, newId, newName) {
try {
- const response = await fetch(`/api/watchlist/artist/${currentArtistId}/link-provider`, {
+ const response = await fetch(`/api/watchlist/artist/${watchlistArtistId}/link-provider`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ provider_id: newProviderId, provider: provider })
+ body: JSON.stringify({ provider_id: newId, provider: sourceKey })
});
-
const data = await response.json();
if (!data.success) {
- showToast(`Failed to link artist: ${data.error}`, 'error');
+ showToast(`Failed to link: ${data.error}`, 'error');
return;
}
-
- showToast(`Linked to "${newProviderName}" on ${provider}`, 'success');
-
- // Close and reopen the config modal with the new ID to refresh everything
+ showToast(`Linked to "${newName}" on ${sourceKey}`, 'success');
+ // Refresh the modal
+ const panel = document.getElementById('wl-linked-search-panel');
+ const artistName = panel?.dataset?.artistName || newName;
closeWatchlistArtistConfigModal();
- setTimeout(() => {
- openWatchlistArtistConfigModal(newProviderId, newProviderName);
- }, 300);
-
+ setTimeout(() => openWatchlistArtistConfigModal(watchlistArtistId, artistName), 300);
} catch (err) {
- console.error('Error linking provider artist:', err);
showToast('Failed to link artist', 'error');
}
}
+async function _clearSourceMatch(sourceKey, watchlistArtistId, artistName) {
+ try {
+ const response = await fetch(`/api/watchlist/artist/${watchlistArtistId}/link-provider`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ provider_id: '', provider: sourceKey })
+ });
+ const data = await response.json();
+ if (!data.success) {
+ showToast(`Failed to clear: ${data.error}`, 'error');
+ return;
+ }
+ showToast(`Cleared ${sourceKey} match`, 'success');
+ closeWatchlistArtistConfigModal();
+ setTimeout(() => openWatchlistArtistConfigModal(watchlistArtistId, artistName), 300);
+ } catch (err) {
+ showToast('Failed to clear match', 'error');
+ }
+}
+
/**
* Open watchlist artist configuration modal
* @param {string} artistId - Spotify artist ID
diff --git a/webui/static/style.css b/webui/static/style.css
index bda61fca..30beacb4 100644
--- a/webui/static/style.css
+++ b/webui/static/style.css
@@ -17015,120 +17015,98 @@ body.helper-mode-active #dashboard-activity-feed:hover {
}
/* Linked Provider Artist */
-.watchlist-linked-artist-card {
+/* Per-source linked rows */
+.wl-linked-sources {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
+
+.wl-linked-row {
display: flex;
align-items: center;
- gap: 12px;
- padding: 12px 14px;
- background: rgba(255, 255, 255, 0.04);
- border: 1px solid rgba(255, 255, 255, 0.1);
- border-radius: 12px;
+ gap: 8px;
+ padding: 8px 10px;
+ border-radius: 8px;
+ background: rgba(255, 255, 255, 0.03);
+ border: 1px solid rgba(255, 255, 255, 0.06);
}
-.watchlist-linked-artist-img {
- width: 48px;
- height: 48px;
- border-radius: 50%;
- object-fit: cover;
- flex-shrink: 0;
+.wl-linked-row.matched {
+ border-color: rgba(76, 175, 80, 0.15);
}
-.watchlist-linked-artist-img-placeholder {
- width: 48px;
- height: 48px;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.08);
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 20px;
- flex-shrink: 0;
+.wl-linked-row.unmatched {
+ border-color: rgba(255, 255, 255, 0.04);
+ opacity: 0.7;
}
-.watchlist-linked-artist-info {
- flex: 1;
- min-width: 0;
-}
+.wl-linked-icon { font-size: 14px; flex-shrink: 0; width: 20px; text-align: center; }
+.wl-linked-label { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.8); width: 90px; flex-shrink: 0; }
+.wl-linked-status { flex: 1; min-width: 0; font-size: 11px; }
+.wl-linked-id { color: rgba(255,255,255,0.5); font-family: monospace; font-size: 11px; }
+.wl-linked-none { color: rgba(255,255,255,0.25); font-style: italic; }
-.watchlist-linked-artist-name {
- font-size: 14px;
- font-weight: 600;
- color: #fff;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-.watchlist-linked-artist-providers {
- display: flex;
- gap: 6px;
- margin-top: 4px;
-}
-
-.watchlist-provider-badge {
- padding: 2px 8px;
+.wl-linked-fix-btn {
+ padding: 3px 10px;
border-radius: 6px;
font-size: 11px;
font-weight: 600;
- text-transform: uppercase;
- letter-spacing: 0.5px;
-}
-
-.watchlist-provider-badge.spotify {
- background: rgba(30, 215, 96, 0.15);
- color: #1ed760;
- border: 1px solid rgba(30, 215, 96, 0.3);
-}
-
-.watchlist-provider-badge.itunes {
- background: rgba(252, 60, 68, 0.15);
- color: #fc3c44;
- border: 1px solid rgba(252, 60, 68, 0.3);
-}
-
-.watchlist-provider-badge.deezer {
- background: rgba(162, 56, 255, 0.15);
- color: #a238ff;
- border: 1px solid rgba(162, 56, 255, 0.3);
-}
-
-.watchlist-provider-badge.discogs {
- background: rgba(212, 165, 116, 0.15);
- color: #D4A574;
- border: 1px solid rgba(212, 165, 116, 0.3);
-}
-
-.watchlist-linked-mismatch-warning {
- margin-top: 6px;
- font-size: 12px;
- color: #ffc107;
- line-height: 1.3;
-}
-
-.watchlist-linked-mismatch-warning strong {
- color: #fff;
-}
-
-.watchlist-linked-change-btn {
- padding: 6px 14px;
- border-radius: 8px;
- font-size: 12px;
- font-weight: 600;
- color: #ccc;
- background: rgba(255, 255, 255, 0.08);
- border: 1px solid rgba(255, 255, 255, 0.15);
+ color: rgba(255,255,255,0.7);
+ background: rgba(255,255,255,0.06);
+ border: 1px solid rgba(255,255,255,0.1);
cursor: pointer;
- transition: all 0.2s ease;
flex-shrink: 0;
}
-.watchlist-linked-change-btn:hover {
+.wl-linked-fix-btn:hover {
background: rgba(var(--accent-rgb), 0.15);
color: #fff;
border-color: rgba(var(--accent-rgb), 0.3);
}
-/* Linked Provider Search */
+.wl-linked-clear-btn {
+ background: none;
+ border: none;
+ color: rgba(255,255,255,0.2);
+ cursor: pointer;
+ font-size: 14px;
+ padding: 2px 4px;
+ flex-shrink: 0;
+}
+
+.wl-linked-clear-btn:hover { color: #ef4444; }
+
+/* Per-source search panel */
+.wl-linked-search-panel {
+ margin-top: 8px;
+ padding: 10px;
+ background: rgba(255,255,255,0.03);
+ border: 1px solid rgba(255,255,255,0.08);
+ border-radius: 10px;
+}
+
+.wl-linked-search-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 8px;
+ font-size: 12px;
+ font-weight: 600;
+ color: rgba(255,255,255,0.7);
+}
+
+.wl-linked-search-close {
+ background: none;
+ border: none;
+ color: rgba(255,255,255,0.3);
+ cursor: pointer;
+ font-size: 16px;
+}
+
+.wl-linked-search-close:hover { color: #fff; }
+
+/* Keep existing search styles */
.watchlist-linked-search {
margin-top: 12px;
}