diff --git a/public/sw.js b/public/sw.js index 36c522e..e656c12 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,4 +1,4 @@ -const CACHE = 'ns-v75'; +const CACHE = 'ns-v76'; const PRECACHE = ['/', 'index.html', 'manifest.json', 'icon.svg']; const SKIP_PATHS = ['/rest/stream', '/rest/download', '/config.js']; // Auth token params stripped from cache keys so artwork survives across sessions/token refreshes. diff --git a/src/api.js b/src/api.js index d2cc7e0..2d4accb 100644 --- a/src/api.js +++ b/src/api.js @@ -425,6 +425,20 @@ export async function deezerLookupArtistAlbums(artistId, limit=100, artistName=' } catch { return []; } } +// Direct artist lookup by Deezer id — the reliable route when /search/artist doesn't surface a +// low-profile same-name artist (Deezer search is a ranked, incomplete fuzzy match; e.g. the browser +// finds Nana id 80239872 but the search API never returns it). Used by the artist-pin "paste link" +// path. Returns the full _dzArtist shape (or null on miss / bad id). +export async function deezerLookupArtist(artistId) { + try { + const r = await fetch(`${_deezerBase()}/artist/${artistId}`); + if (!r.ok) return null; + const a = await r.json(); + if (!a || a.error || !a.id) return null; + return _dzArtist(a); + } catch { return null; } +} + // Deezer artist photo (for the hero on non-local artist pages). iTunes artist entities had none. export async function deezerArtistImage(artistId) { try { diff --git a/src/ui/artistPin.js b/src/ui/artistPin.js index b6ed00f..5cf0f4e 100644 --- a/src/ui/artistPin.js +++ b/src/ui/artistPin.js @@ -4,8 +4,19 @@ // NovaSonic would otherwise guess the wrong one (fans / top songs / albums / image). // The mapping is stored server-side (shared across users) — see api.js. -import { deezerSearch, setArtistOverride, removeArtistOverride, getArtistOverride } from '../api.js'; -import { esc, fmtCount } from '../utils.js'; +import { deezerSearch, deezerLookupArtist, setArtistOverride, removeArtistOverride, getArtistOverride } from '../api.js'; +import { esc, fmtCount, toast } from '../utils.js'; + +// Pull a Deezer artist id out of whatever the user pastes: a full URL +// (deezer.com/en/artist/80239872, /de/artist/…?…), or a bare id ("80239872"). +function _parseDeezerArtistId(raw) { + const s = String(raw || '').trim(); + if (!s) return null; + const m = s.match(/artist\/(\d+)/i); + if (m) return m[1]; + if (/^\d+$/.test(s)) return s; + return null; +} let _overlay = null; let _ctx = null; // { ndArtistId, ndName } @@ -50,7 +61,20 @@ async function _render() { const clearBtn = cur ? `` : ''; - body.innerHTML = clearBtn + `