Spaces:
Paused
Paused
feat(api): /api/poster-refresh 추가 — namu CDN URL 만료 정조준 캐시 삭제
Browse filesnamu CDN(i.namu.wiki) URL은 시그니처/경로가 만료되는데
fetchNamuPoster는 readCachePermanent로 영구 캐시라 자동 갱신 안 됨.
/api/flush는 전체 캐시를 날려 부작용이 큼.
titles=A,B (namu_poster_v2_* 캐시) + ids=1,2 (ep_*.json / ani_ep_*.json)
를 정조준 삭제. 이후 ep 호출 시 자연스럽게 새 URL 재취득.
server.js
CHANGED
|
@@ -2376,6 +2376,24 @@ async function handleApi(req, res, parsed) {
|
|
| 2376 |
for (const f of fs.readdirSync(CACHE_DIR)) if (f.endsWith('.json')) fs.unlinkSync(path.join(CACHE_DIR, f));
|
| 2377 |
out = { ok: true };
|
| 2378 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2379 |
else if (p === '/api/breaker') {
|
| 2380 |
// 디버그/관리용: anilife circuit breaker 상태 확인 + 강제 리셋
|
| 2381 |
if (q.reset === '1') {
|
|
|
|
| 2376 |
for (const f of fs.readdirSync(CACHE_DIR)) if (f.endsWith('.json')) fs.unlinkSync(path.join(CACHE_DIR, f));
|
| 2377 |
out = { ok: true };
|
| 2378 |
}
|
| 2379 |
+
else if (p === '/api/poster-refresh') {
|
| 2380 |
+
// namu CDN URL 만료 시 정조준 캐시 삭제. titles=A,B 그리고/또는 ids=1,2 (ep 캐시까지 함께)
|
| 2381 |
+
const titles = String(q.titles || '').split(',').map(s => s.trim()).filter(Boolean);
|
| 2382 |
+
const ids = String(q.ids || '').split(',').map(s => parseInt(s, 10)).filter(Boolean);
|
| 2383 |
+
const removed = [];
|
| 2384 |
+
for (const t of titles) {
|
| 2385 |
+
const fn = `namu_poster_v2_${Buffer.from(t).toString('base64').slice(0, 80).replace(/[+/=]/g, '_')}.json`;
|
| 2386 |
+
const fp = path.join(CACHE_DIR, fn);
|
| 2387 |
+
if (fs.existsSync(fp)) { try { fs.unlinkSync(fp); removed.push(fn); } catch {} }
|
| 2388 |
+
}
|
| 2389 |
+
for (const id of ids) {
|
| 2390 |
+
for (const fn of [`ep_${id}.json`, `ani_ep_${id}.json`]) {
|
| 2391 |
+
const fp = path.join(CACHE_DIR, fn);
|
| 2392 |
+
if (fs.existsSync(fp)) { try { fs.unlinkSync(fp); removed.push(fn); } catch {} }
|
| 2393 |
+
}
|
| 2394 |
+
}
|
| 2395 |
+
out = { ok: true, removed };
|
| 2396 |
+
}
|
| 2397 |
else if (p === '/api/breaker') {
|
| 2398 |
// 디버그/관리용: anilife circuit breaker 상태 확인 + 강제 리셋
|
| 2399 |
if (q.reset === '1') {
|