fix: consistent artist parsing across player, NP overlay, and song list
Extract parseArtists() helper — uses Navidrome's resolved artists array when it has multiple entries, otherwise splits artist string on ';' only. Removes old split on / that broke Au/Ra, HUNTR/X etc everywhere. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b4e221881
commit
467ee8a0fe
2 files changed
+16
-14
No files matched your search
+14
-10
@@ -442,14 +442,20 @@ function _updatePlayingHighlights() {
|
||||
});
|
||||
}
|
||||
|
||||
// Returns [{name, id}] using Navidrome's resolved artists when available,
|
||||
// otherwise splits the artist string on ';' only (safe for names like Au/Ra).
|
||||
export function parseArtists(s) {
|
||||
if (Array.isArray(s.artists) && s.artists.length > 1) return s.artists;
|
||||
return (s.artist || '').split(/\s*;\s*/).filter(Boolean)
|
||||
.map((name, i) => ({ name, id: i === 0 ? (s.artistId || '') : '' }));
|
||||
}
|
||||
|
||||
export function updatePlayerUI(s, _skipMediaSession = false) {
|
||||
document.getElementById('player-title').textContent = s.title;
|
||||
const artistParts = (s.artist || '').split(/\s*(?:\/|•|,)\s*/).filter(Boolean);
|
||||
const artistParts = parseArtists(s);
|
||||
document.getElementById('player-artist-name').innerHTML = artistParts.length
|
||||
? artistParts.map((name, i) => {
|
||||
const aid = i === 0 ? (s.artistId || '') : '';
|
||||
return `<span style="cursor:pointer" onclick="s_goArtist(event,'${esc(name)}','${aid}')">${esc(name)}</span>`;
|
||||
}).join('<span style="color:var(--text3)"> • </span>')
|
||||
? artistParts.map(a => `<span style="cursor:pointer" onclick="s_goArtist(event,'${esc(a.name)}','${a.id||''}')">${esc(a.name)}</span>`)
|
||||
.join('<span style="color:var(--text3)"> • </span>')
|
||||
: '—';
|
||||
document.getElementById('player-album-name').textContent = s.album || '';
|
||||
const art = document.getElementById('player-art');
|
||||
@@ -515,12 +521,10 @@ export function _syncNpDirect(s) {
|
||||
const t = document.getElementById('np-title'); if(t) t.textContent = s.title || '—';
|
||||
const an = document.getElementById('np-artist-name');
|
||||
if(an) {
|
||||
const parts = (s.artist || '').split(/\s*(?:\/|•|,)\s*/).filter(Boolean);
|
||||
const parts = parseArtists(s);
|
||||
an.innerHTML = parts.length
|
||||
? parts.map((name, i) => {
|
||||
const aid = i === 0 ? (s.artistId || '') : '';
|
||||
return `<span style="cursor:pointer" onclick="closeNowPlaying();s_goArtist(event,'${esc(name)}','${aid}')">${esc(name)}</span>`;
|
||||
}).join('<span style="opacity:.5"> • </span>')
|
||||
? parts.map(a => `<span style="cursor:pointer" onclick="closeNowPlaying();s_goArtist(event,'${esc(a.name)}','${a.id||''}')">${esc(a.name)}</span>`)
|
||||
.join('<span style="opacity:.5"> • </span>')
|
||||
: '—';
|
||||
}
|
||||
const aln = document.getElementById('np-album-name'); if(aln) aln.textContent = s.album || '';
|
||||
|
||||
Reference in new issue
Block a user