diff --git a/server/admin-tools.js b/server/admin-tools.js index c12d157..2b8ef6f 100644 --- a/server/admin-tools.js +++ b/server/admin-tools.js @@ -360,7 +360,11 @@ export function registerAdminToolsRoutes(app, { db, adminAuth, media = null, bac } finally { activeJobId = null; workerBusy = false; } } if (autoStartJobs) { - sql.execute("UPDATE admin_lyrics_jobs SET status='queued',updated_at=unixepoch() WHERE status='running'").then(() => runBulkJob()).catch(error => console.warn('[admin-tools] could not resume lyrics jobs:', error.message)); + // The table is created by the schema setup, which may still be running at + // start-up: retry until it exists rather than skipping the resume. + const resume = (tries = 0) => sql.execute("UPDATE admin_lyrics_jobs SET status='queued',updated_at=unixepoch() WHERE status='running'").then(() => runBulkJob()) + .catch(error => { if (/no such table/.test(error.message) && tries < 30) setTimeout(() => resume(tries + 1), 2000).unref?.(); else console.warn('[admin-tools] could not resume lyrics jobs:', error.message); }); + resume(); const timer = setInterval(runBulkJob, 1000); timer.unref?.(); } diff --git a/server/recommendations.js b/server/recommendations.js index 12c2aef..a177b26 100644 --- a/server/recommendations.js +++ b/server/recommendations.js @@ -87,7 +87,11 @@ export function registerCatalogRoutes(app, { resolveListener = async (c, name, f const discovery = c.req.method === 'GET' && !/^\/api\/admin\/(analytics|metadata|collections)(\/|$)/.test(path) && !path.startsWith('/api/catalog/') && path !== '/api/recommendations'; try { if (discovery && c.res.headers.get('content-type')?.includes('application/json')) { - const result = await c.res.clone().json(); + // /api/search answers gzipped; read the body decompressed. + const res = c.res.clone(); + const result = res.headers.get('content-encoding') === 'gzip' + ? JSON.parse(new TextDecoder().decode(Bun.gunzipSync(new Uint8Array(await res.arrayBuffer())))) + : await res.json(); if (typeof result.data === 'string') { try { result.data = JSON.parse(result.data); } catch { /* invalid profile */ } } await ingest(extractCards(result), path.includes('search') ? 'search-cache' : path.includes('channel') ? 'channel' : path.includes('streams') ? 'streams' : 'playlist'); }