fix(web): 'Unknown Artist' download from artist page + rename itunes*→deezer* identifiers
Fix (the reported bug):
- Deezer's /artist/{id}/albums omits the artist object, so discography album cards had an
empty artist name → the download modal fell back to the literal "Unknown Artist", which
poisoned the yt-dlp search ("Unknown Artist <album>") and its artist/channel filter, failing
with "Nicht eindeutig gefunden".
- deezerLookupArtistAlbums now backfills the known artist name (we're on that artist's page).
- openDlModal now defaults album cards to an ALBUM download (was always Track), so a one-click
download no longer grabs an album as a single track named after the album.
Rename (requested cleanup, dependency-checked so nothing breaks):
- All frontend itunes* identifiers → deezer* (functions, the ItunesItem-shape field keys
itunesData/itunesArtistId/itunesFanCount/itunesId, the itunes-album-detail route + DOM ids,
the badge-itunes CSS class). The backend reads none of these fields, so the boundary is safe.
- Verified: build passes; route/DOM-id/CSS producer↔consumer all consistent; only the factual
"Apple's iTunes /search 403" comments keep the historical name. SW ns-v62.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc87a04da5
commit
1e206e8df3
13 files changed
+118
-108
No files matched your search
+40
-40
@@ -1,6 +1,6 @@
|
||||
import { S } from '../state.js';
|
||||
import { esc, toast, fmtCount } from '../utils.js';
|
||||
import { api, coverUrl, itunesSearch, itunesLookupAlbum, itunesLookupArtistSongs, itunesLookupArtistAlbums, deezerArtistImage, fetchRomajiIndex, dispArtistById, dispAlbumName, cacheArtistSortNames, ensureArtistSortMap } from '../api.js';
|
||||
import { api, coverUrl, deezerSearch, deezerLookupAlbum, deezerLookupArtistSongs, deezerLookupArtistAlbums, deezerArtistImage, fetchRomajiIndex, dispArtistById, dispAlbumName, cacheArtistSortNames, ensureArtistSortMap } from '../api.js';
|
||||
import { makeCard, makeAlbumCard, makeGlobalTrackItem, makeSongItem } from '../ui/components.js';
|
||||
import { playQueue, dlSongLocal, toggleStar, parseArtists } from '../player/player.js';
|
||||
import { showCtxMenu, openDlModal } from '../ui/ui.js';
|
||||
@@ -87,8 +87,8 @@ export async function loadArtistDetail(artist) {
|
||||
if(albEl) albEl.innerHTML = '<div class="spinner"></div>';
|
||||
|
||||
const hasND = !!artist.id;
|
||||
const knownItunes = artist.itunesArtistId || null;
|
||||
const knownFans = artist.itunesFanCount ?? null;
|
||||
const knownDeezer = artist.deezerArtistId || null;
|
||||
const knownFans = artist.deezerFanCount ?? null;
|
||||
if (knownFans) _showFans(knownFans); // from the global-search card — show immediately
|
||||
|
||||
// Fire all requests immediately so they run in parallel.
|
||||
@@ -96,7 +96,7 @@ export async function loadArtistDetail(artist) {
|
||||
const albumP = hasND ? api('getArtist', `&id=${artist.id}`) : Promise.resolve(null);
|
||||
const infoP = hasND ? api('getArtistInfo2',`&id=${artist.id}&count=8`) : Promise.resolve(null);
|
||||
const topP = hasND ? api('getTopSongs', `&artist=${encodeURIComponent(artist.name)}&count=10`) : Promise.resolve(null);
|
||||
const iArtistP = knownItunes ? Promise.resolve([{ artistId: knownItunes }]) : itunesSearch(artist.name, 'musicArtist', 5);
|
||||
const iArtistP = knownDeezer ? Promise.resolve([{ artistId: knownDeezer }]) : deezerSearch(artist.name, 'musicArtist', 5);
|
||||
const eventsP = fetchEvents(artist.name);
|
||||
|
||||
// Phase 1 — hero: only wait for albumP (fast local Navidrome call, no external API).
|
||||
@@ -138,7 +138,7 @@ export async function loadArtistDetail(artist) {
|
||||
document.getElementById('artist-hero-pfp-initial')?.style.setProperty('display', 'none');
|
||||
}).catch(() => {});
|
||||
|
||||
// Phase 2 — content (may be slow: Last.fm bio, iTunes, events)
|
||||
// Phase 2 — content (may be slow: Last.fm bio, Deezer, events)
|
||||
const [infoRes, topRes, iArtistRes, eventsRes] = await Promise.allSettled([infoP, topP, iArtistP, eventsP]);
|
||||
|
||||
const _normWords = s => new Set((s || '').toLowerCase().replace(/[^a-z0-9]/g, ' ').split(/\s+/).filter(Boolean));
|
||||
@@ -163,7 +163,7 @@ export async function loadArtistDetail(artist) {
|
||||
// artist we own songs for, prefer the Deezer candidate whose top tracks actually overlap our
|
||||
// library — each artist has different songs, so this nails the right person. Only runs on a real
|
||||
// collision (≥2 name matches) and costs a few calls just for those.
|
||||
if (!knownItunes && hasND && nameMatches.length > 1) {
|
||||
if (!knownDeezer && hasND && nameMatches.length > 1) {
|
||||
const _nt = s => (s || '').toLowerCase().replace(/\([^)]*\)/g, '').replace(/[^a-z0-9]/g, '');
|
||||
const refTitles = new Set(
|
||||
((topRes.status === 'fulfilled' ? topRes.value?.topSongs?.song : []) || [])
|
||||
@@ -172,7 +172,7 @@ export async function loadArtistDetail(artist) {
|
||||
if (refTitles.size) {
|
||||
const cands = nameMatches.slice(0, 3);
|
||||
const scored = await Promise.all(cands.map(async c => {
|
||||
const tt = await itunesLookupArtistSongs(c.artistId, 15).catch(() => []);
|
||||
const tt = await deezerLookupArtistSongs(c.artistId, 15).catch(() => []);
|
||||
const overlap = tt.reduce((n, t) => n + (refTitles.has(_nt(t.trackName)) ? 1 : 0), 0);
|
||||
return { c, overlap };
|
||||
}));
|
||||
@@ -181,12 +181,12 @@ export async function loadArtistDetail(artist) {
|
||||
}
|
||||
}
|
||||
|
||||
const itunesArtistId = knownItunes ?? iArtistMatch?.artistId ?? null;
|
||||
const deezerArtistId = knownDeezer ?? iArtistMatch?.artistId ?? null;
|
||||
if (!knownFans) _showFans(iArtistMatch?.fanCount); // local artist: show the matched Deezer artist's fans
|
||||
|
||||
// Non-local (Deezer) artist has no Navidrome photo — fetch the Deezer artist picture for the hero.
|
||||
if (!hasND && itunesArtistId && pfpWrap) {
|
||||
const dzImg = iArtistMatch?.artworkUrl100 || await deezerArtistImage(itunesArtistId);
|
||||
if (!hasND && deezerArtistId && pfpWrap) {
|
||||
const dzImg = iArtistMatch?.artworkUrl100 || await deezerArtistImage(deezerArtistId);
|
||||
if (dzImg) {
|
||||
const pfpImg = document.createElement('img');
|
||||
pfpImg.className = 'artist-hero-pfp';
|
||||
@@ -197,10 +197,10 @@ export async function loadArtistDetail(artist) {
|
||||
}
|
||||
}
|
||||
|
||||
const [iAlbumsRes, iTracksRes] = itunesArtistId
|
||||
const [iAlbumsRes, iTracksRes] = deezerArtistId
|
||||
? await Promise.allSettled([
|
||||
itunesLookupArtistAlbums(itunesArtistId),
|
||||
itunesLookupArtistSongs(itunesArtistId, 15),
|
||||
deezerLookupArtistAlbums(deezerArtistId, 100, artist.name),
|
||||
deezerLookupArtistSongs(deezerArtistId, 15),
|
||||
])
|
||||
: [{ status: 'rejected' }, { status: 'rejected' }];
|
||||
|
||||
@@ -332,7 +332,7 @@ async function _renderArtistAlbums(el, ndAlbums, iAlbums, artist) {
|
||||
await Promise.all(entries
|
||||
.filter(e => e.match && !(e.ia.trackCount > 0) && e.ia.collectionId)
|
||||
.map(async e => {
|
||||
const tracks = await itunesLookupAlbum(e.ia.collectionId).catch(() => []);
|
||||
const tracks = await deezerLookupAlbum(e.ia.collectionId).catch(() => []);
|
||||
if (tracks.length) e.ia = { ...e.ia, trackCount: tracks.length };
|
||||
}));
|
||||
|
||||
@@ -342,11 +342,11 @@ async function _renderArtistAlbums(el, ndAlbums, iAlbums, artist) {
|
||||
if(!match) { notDl.push(ia); continue; }
|
||||
const have = match.songCount || 0;
|
||||
const total = ia.trackCount || 0;
|
||||
if(total > have) { partial.push({ nd: match, itunes: ia, have, total }); usedNdIds.add(match.id); }
|
||||
else { downloaded.push({ nd: match, itunes: ia }); usedNdIds.add(match.id); }
|
||||
if(total > have) { partial.push({ nd: match, deezer: ia, have, total }); usedNdIds.add(match.id); }
|
||||
else { downloaded.push({ nd: match, deezer: ia }); usedNdIds.add(match.id); }
|
||||
}
|
||||
for(const na of ndAlbums) {
|
||||
if(!usedNdIds.has(na.id)) downloaded.push({ nd: na, itunes: null });
|
||||
if(!usedNdIds.has(na.id)) downloaded.push({ nd: na, deezer: null });
|
||||
}
|
||||
|
||||
el.innerHTML = '';
|
||||
@@ -370,20 +370,20 @@ async function _renderArtistAlbums(el, ndAlbums, iAlbums, artist) {
|
||||
}
|
||||
if(partial.length) {
|
||||
const g = addGrid('Unvollständig', partial.length);
|
||||
partial.forEach(({ nd, itunes, have, total }) => {
|
||||
const art = itunes?.artworkUrl100?.replace('100x100','512x512') || coverUrl(nd.coverArt, 512);
|
||||
partial.forEach(({ nd, deezer, have, total }) => {
|
||||
const art = deezer?.artworkUrl100?.replace('100x100','512x512') || coverUrl(nd.coverArt, 512);
|
||||
const c = makeCard(nd.name, `${have} / ${total} Tracks`, art, '💿');
|
||||
c.querySelector('.card-art').onclick = (e) => { e.stopPropagation(); quickPlayAlbum(nd); };
|
||||
c.querySelector('.card-info').onclick = () => itunes ? navigate('partial-album-detail', { nd, itunes }) : navigate('album-detail', { ...nd, _fromArtist: artist });
|
||||
c.querySelector('.card-info').onclick = () => deezer ? navigate('partial-album-detail', { nd, deezer }) : navigate('album-detail', { ...nd, _fromArtist: artist });
|
||||
const artEl = c.querySelector('.card-art');
|
||||
const badge = document.createElement('div');
|
||||
badge.className = 'album-partial-badge'; badge.textContent = `${have}/${total}`;
|
||||
artEl.appendChild(badge);
|
||||
if(itunes) {
|
||||
if(deezer) {
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'card-dl-btn'; btn.title = 'Fehlende Tracks laden';
|
||||
btn.innerHTML = `<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`;
|
||||
btn.onclick = (e) => { e.stopPropagation(); openDlModal({ artistName: artist.name, trackName: nd.name, collectionName: nd.name, artworkUrl100: itunes.artworkUrl100||'', isAlbum: true, itunesData: itunes, collectionId: itunes.collectionId }); };
|
||||
btn.onclick = (e) => { e.stopPropagation(); openDlModal({ artistName: artist.name, trackName: nd.name, collectionName: nd.name, artworkUrl100: deezer.artworkUrl100||'', isAlbum: true, deezerData: deezer, collectionId: deezer.collectionId }); };
|
||||
artEl.appendChild(btn);
|
||||
}
|
||||
g.appendChild(c);
|
||||
@@ -394,12 +394,12 @@ async function _renderArtistAlbums(el, ndAlbums, iAlbums, artist) {
|
||||
notDl.forEach(ia => {
|
||||
const art = ia.artworkUrl100?.replace('100x100','300x300');
|
||||
const c = makeCard(ia.collectionName, ia.releaseDate?.slice(0,4)||'', art, '💿');
|
||||
c.onclick = () => navigate('itunes-album-detail', ia);
|
||||
c.onclick = () => navigate('deezer-album-detail', ia);
|
||||
const artEl = c.querySelector('.card-art');
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'card-dl-btn'; btn.title = 'Album laden';
|
||||
btn.innerHTML = `<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`;
|
||||
btn.onclick = (e) => { e.stopPropagation(); openDlModal({ artistName: ia.artistName, trackName: ia.collectionName, collectionName: ia.collectionName, artworkUrl100: ia.artworkUrl100||'', isAlbum: true, itunesData: ia, collectionId: ia.collectionId }); };
|
||||
btn.onclick = (e) => { e.stopPropagation(); openDlModal({ artistName: ia.artistName, trackName: ia.collectionName, collectionName: ia.collectionName, artworkUrl100: ia.artworkUrl100||'', isAlbum: true, deezerData: ia, collectionId: ia.collectionId }); };
|
||||
artEl.appendChild(btn);
|
||||
g.appendChild(c);
|
||||
});
|
||||
@@ -438,32 +438,32 @@ export async function loadArtistAllSongs({ albums, artist }) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadItunesAlbumDetail(album) {
|
||||
document.getElementById('itunes-album-back-btn').onclick = () => _navGoBack();
|
||||
document.getElementById('itunes-album-detail-name').textContent = album.collectionName || '—';
|
||||
document.getElementById('itunes-album-detail-artist').textContent = album.artistName || '';
|
||||
const cw = document.getElementById('itunes-album-cover-wrap');
|
||||
export async function loadDeezerAlbumDetail(album) {
|
||||
document.getElementById('deezer-album-back-btn').onclick = () => _navGoBack();
|
||||
document.getElementById('deezer-album-detail-name').textContent = album.collectionName || '—';
|
||||
document.getElementById('deezer-album-detail-artist').textContent = album.artistName || '';
|
||||
const cw = document.getElementById('deezer-album-cover-wrap');
|
||||
const art = (album.artworkUrl100 || '').replace('100x100bb','600x600bb').replace('100x100','600x600');
|
||||
cw.innerHTML = art ? `<img src="${art}" onerror="_imgRetry(this,'💿')">` : '<div class="no-art">💿</div>';
|
||||
const dlBtn = document.getElementById('itunes-album-dl-btn');
|
||||
dlBtn.onclick = () => openDlModal({ artistName: album.artistName, trackName: album.collectionName, collectionName: album.collectionName, artworkUrl100: album.artworkUrl100||'', isAlbum: true, itunesData: album, collectionId: album.collectionId });
|
||||
const sl = document.getElementById('itunes-album-songs');
|
||||
const dlBtn = document.getElementById('deezer-album-dl-btn');
|
||||
dlBtn.onclick = () => openDlModal({ artistName: album.artistName, trackName: album.collectionName, collectionName: album.collectionName, artworkUrl100: album.artworkUrl100||'', isAlbum: true, deezerData: album, collectionId: album.collectionId });
|
||||
const sl = document.getElementById('deezer-album-songs');
|
||||
sl.innerHTML = '<div class="spinner"></div>';
|
||||
try {
|
||||
const tracks = await itunesLookupAlbum(album.collectionId);
|
||||
const tracks = await deezerLookupAlbum(album.collectionId);
|
||||
const year = album.releaseDate ? new Date(album.releaseDate).getFullYear() : '';
|
||||
document.getElementById('itunes-album-detail-stats').textContent = `${tracks.length} Titel${year ? ' · ' + year : ''}`;
|
||||
document.getElementById('deezer-album-detail-stats').textContent = `${tracks.length} Titel${year ? ' · ' + year : ''}`;
|
||||
sl.innerHTML = '';
|
||||
if(!tracks.length) { sl.innerHTML = '<div style="padding:16px;color:var(--text3)">Keine Tracks gefunden</div>'; return; }
|
||||
tracks.forEach((t, i) => sl.appendChild(makeGlobalTrackItem(t, i, tracks)));
|
||||
} catch(e) { sl.innerHTML = `<p style="color:var(--danger)">${e.message}</p>`; }
|
||||
}
|
||||
|
||||
export async function loadPartialAlbumDetail({ nd, itunes }) {
|
||||
export async function loadPartialAlbumDetail({ nd, deezer }) {
|
||||
document.getElementById('partial-album-back-btn').onclick = () => _navGoBack();
|
||||
document.getElementById('partial-album-detail-name').textContent = nd.name || '—';
|
||||
document.getElementById('partial-album-detail-artist').textContent = nd.artist || itunes?.artistName || '';
|
||||
const art = (itunes?.artworkUrl100 || '').replace('100x100bb','600x600bb').replace('100x100','600x600')
|
||||
document.getElementById('partial-album-detail-artist').textContent = nd.artist || deezer?.artistName || '';
|
||||
const art = (deezer?.artworkUrl100 || '').replace('100x100bb','600x600bb').replace('100x100','600x600')
|
||||
|| (nd.coverArt ? coverUrl(nd.coverArt, 512) : '');
|
||||
const cw = document.getElementById('partial-album-cover-wrap');
|
||||
cw.innerHTML = art ? `<img src="${art}" onerror="_imgRetry(this,'💿')">` : '<div class="no-art">💿</div>';
|
||||
@@ -476,7 +476,7 @@ export async function loadPartialAlbumDetail({ nd, itunes }) {
|
||||
try {
|
||||
const [ndRes, iTracks] = await Promise.all([
|
||||
api('getAlbum', `&id=${nd.id}`),
|
||||
itunes?.collectionId ? itunesLookupAlbum(itunes.collectionId) : Promise.resolve([]),
|
||||
deezer?.collectionId ? deezerLookupAlbum(deezer.collectionId) : Promise.resolve([]),
|
||||
]);
|
||||
const ndSongs = (ndRes.album?.song || []).sort((a,b) => (a.track||999)-(b.track||999));
|
||||
|
||||
@@ -492,9 +492,9 @@ export async function loadPartialAlbumDetail({ nd, itunes }) {
|
||||
if(ndSongs.length) playQueue(ndSongs, 0);
|
||||
};
|
||||
|
||||
// Download button offers missing via iTunes
|
||||
// Download button offers missing via Deezer
|
||||
document.getElementById('partial-album-dl-btn').onclick = () => {
|
||||
if(itunes) openDlModal({ artistName: itunes.artistName, trackName: itunes.collectionName, collectionName: itunes.collectionName, artworkUrl100: itunes.artworkUrl100||'', isAlbum: true, itunesData: itunes, collectionId: itunes.collectionId });
|
||||
if(deezer) openDlModal({ artistName: deezer.artistName, trackName: deezer.collectionName, collectionName: deezer.collectionName, artworkUrl100: deezer.artworkUrl100||'', isAlbum: true, deezerData: deezer, collectionId: deezer.collectionId });
|
||||
};
|
||||
|
||||
// Section: downloaded
|
||||
|
||||
Reference in new issue
Block a user