dongsik22 Claude Opus 4.7 (1M context) commited on
Commit
e8002a0
·
1 Parent(s): e18993f

fix: vod_class 요일이 카테고리로 들어가던 사고 + 나무위키 띄어쓰기 변형

Browse files

증상: "나혼자 산다" 카드 카테고리 "금요일", 포스터 없음.
원인:
1. tvchak vod_class가 일부 작품(나혼자 산다 등 정규 방송 예능)에서
요일을 반환 → 클라이언트 index.html:2060이 그대로 fav.category에
저장. 화이트리스트 검증 없었음.
2. 나무위키 표제어는 "나 혼자 산다"(띄어쓰기) — namuTitleCandidates가
공백 변형을 생성하지 않아 8개 후보 모두 404.

조치:
- 클라이언트: vod_class를 fav.category로 받기 전 화이트리스트 정규식
(드라마|예능|영화|애니|시사교양|다큐|키즈|스포츠) 통과만 저장.
- 서버 fetchEpisodes: 반환 직전 category도 동일 화이트리스트 통과.
검색 meta에서 추출된 잘못된 값도 차단.
- namuTitleCandidates: 공백 모두 제거 + 첫 한글 1글자 뒤 공백 삽입
변형 추가 (disambiguation suffix 형태도 포함).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (2) hide show
  1. index.html +8 -3
  2. server.js +18 -0
index.html CHANGED
@@ -2057,10 +2057,15 @@ async function playEpisode(id, sid, nid, opts = {}) {
2057
  }
2058
 
2059
  // E2: 카테고리 백업 캐싱 (fetchEpisodes에서 못 가져왔으면 play 응답에서 채움)
 
2060
  if (fav && src === 'tvchak' && !fav.category && p.vod_data?.vod_class) {
2061
- fav.category = p.vod_data.vod_class;
2062
- saveFavs();
2063
- renderFavs();
 
 
 
 
2064
  }
2065
  const title = (p.vod_data && p.vod_data.vod_name) || (fav && fav.title) || '';
2066
  const ep = currentEpList.find(e => e.sid === sid && e.nid === nid) || currentEpList.find(e => e.nid === nid);
 
2057
  }
2058
 
2059
  // E2: 카테고리 백업 캐싱 (fetchEpisodes에서 못 가져왔으면 play 응답에서 채움)
2060
+ // 가드: tvchak vod_class는 종종 "금요일" 같은 방송요일을 반환함 → 화이트리스트 통과만 저장.
2061
  if (fav && src === 'tvchak' && !fav.category && p.vod_data?.vod_class) {
2062
+ const vc = String(p.vod_data.vod_class);
2063
+ const m = vc.match(/(드라마|예능|영화|애니|시사교양|다큐|키즈|스포츠)/);
2064
+ if (m) {
2065
+ fav.category = m[1];
2066
+ saveFavs();
2067
+ renderFavs();
2068
+ }
2069
  }
2070
  const title = (p.vod_data && p.vod_data.vod_name) || (fav && fav.title) || '';
2071
  const ep = currentEpList.find(e => e.sid === sid && e.nid === nid) || currentEpList.find(e => e.nid === nid);
server.js CHANGED
@@ -1357,6 +1357,11 @@ async function fetchEpisodes(id, opts = {}) {
1357
  catch (e) { console.warn(`[ep ${id}] namu poster failed:`, e.message); }
1358
  }
1359
 
 
 
 
 
 
1360
  const out = {
1361
  id,
1362
  title: result.title,
@@ -1404,6 +1409,19 @@ function namuTitleCandidates(title) {
1404
  // 시리즈 이름만 (첫 어절): "나는 SOLO 그후 사랑은 계속된다" → "나는 SOLO"
1405
  const words = base.split(/\s+/);
1406
  if (words.length >= 2) push(words.slice(0, 2).join(' '));
 
 
 
 
 
 
 
 
 
 
 
 
 
1407
  return out.filter(t => t.length >= 2);
1408
  }
1409
 
 
1357
  catch (e) { console.warn(`[ep ${id}] namu poster failed:`, e.message); }
1358
  }
1359
 
1360
+ // 화이트리스트 통과만 category로 인정 — 사이트가 "금요일" 같은 요일을 vod_class로 주는 케이스 차단.
1361
+ if (category) {
1362
+ const m = String(category).match(/(드라마|예능|영화|애니|시사교양|다큐|키즈|스포츠)/);
1363
+ category = m ? m[1] : null;
1364
+ }
1365
  const out = {
1366
  id,
1367
  title: result.title,
 
1409
  // 시리즈 이름만 (첫 어절): "나는 SOLO 그후 사랑은 계속된다" → "나는 SOLO"
1410
  const words = base.split(/\s+/);
1411
  if (words.length >= 2) push(words.slice(0, 2).join(' '));
1412
+ // 띄어쓰기 변형 — 사이트는 "나혼자 산다"로, 나무위키는 "나 혼자 산다"로 표기되는 케이스.
1413
+ // - 공백 모두 제거: "나혼자 산다" → "나혼자산다"
1414
+ // - 첫 한글 1글자 뒤 공백 삽입: "나혼자 산다" → "나 혼자 산다"
1415
+ const noSpace = base.replace(/\s+/g, '');
1416
+ push(noSpace);
1417
+ const m1 = base.match(/^([가-힣])([가-힣].*)/);
1418
+ if (m1) {
1419
+ push(`${m1[1]} ${m1[2]}`);
1420
+ // disambiguation suffix도 동일 변형으로
1421
+ if (!/\([^)]+\)$/.test(base)) {
1422
+ for (const sfx of NAMU_DISAMBIG_SUFFIXES) push(`${m1[1]} ${m1[2]}(${sfx})`);
1423
+ }
1424
+ }
1425
  return out.filter(t => t.length >= 2);
1426
  }
1427