Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263/** * Ask Navidrome the question the crawl cannot answer about itself. * * `harvest incomplete — 22,353 of 22,375 tracks, counted twice` says the server holds a count it will * not hand rows for, and cannot say why. This asks it directly: the same list endpoint, counted three * ways, using the credentials the tab already holds. Four GETs and a login, nothing written. * * **Paste the whole file into the devtools console** of a running hackermusic tab (it reads * `hackermusic.connection.v1`, so the tab has to be logged in). Node cannot run it: it needs the * browser's `localStorage` and the session's CORS posture — which is itself part of what is being * measured. */(async () => { const raw = localStorage.getItem("hackermusic.connection.v1"); if (!raw) return console.error("no connection in this tab — log in first"); const conn = JSON.parse(raw); const host = conn.host.replace(/\/+$/, "");
const login = await fetch(`${host}/auth/login`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ username: conn.username, password: conn.password }), }); if (!login.ok) return console.error("login refused", login.status); const body = await login.json(); const jwt = body.access_token ?? body.token; if (!jwt) return console.error("no token in the login body", body);
/** One row, because the number we want is the `x-total-count` header, not the body. */ const count = async (label, filter) => { const url = `${host}/api/song?_start=0&_end=0&_sort=id&_order=asc${filter}`; const res = await fetch(url, { headers: { "x-nd-authorization": `Bearer ${jwt}` } }); const rows = res.ok ? (await res.json()).length : -1; console.log( label.padEnd(16), "count:", String(res.headers.get("x-total-count")).padEnd(8), "rows:", String(rows).padEnd(6), "http:", res.status, ); return Number(res.headers.get("x-total-count")); };
console.log(`— ${conn.username}@${host} —`); const all = await count("everything", ""); const present = await count("not missing", "&missing=false"); const missing = await count("missing", "&missing=true"); const albums = await fetch(`${host}/api/album?_start=0&_end=0`, { headers: { "x-nd-authorization": `Bearer ${jwt}` }, }); console.log("albums".padEnd(16), "count:", albums.headers.get("x-total-count"));
console.log( all - present === missing && present > 0 ? `\n${missing} files are flagged missing: Navidrome counts them and will not list them. ` + `If the crawl came up short by exactly that many, that is the whole story.` : `\nmissing-flagged files do not account for the gap (${all} counted, ${present} listed, ` + `${missing} flagged). Then the suspect is this login's folder access, not the scanner.`, );})();