From 9ab3c9258ed48cbe6e1917cb10f75bf6ca692e23 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Thu, 29 Oct 2026 11:06:04 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9B=90=EA=B3=A1=EC=B0=BE=EA=B8=B0:=20MV?= =?UTF-8?q?=C2=B7inst.=C2=B7=EB=9D=BC=EC=9D=B4=EB=B8=8C=C2=B7=EC=BB=A4?= =?UTF-8?q?=EB=B2=84=EB=8A=94=20=EA=B8=B8=EC=9D=B4=EA=B0=80=20=EA=B0=99?= =?UTF-8?q?=EC=95=84=EB=8F=84=20=ED=99=95=EC=A0=95=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EC=9D=8C=20=E2=80=94=20=EA=B2=80=EC=83=89=20=EC=A4=84?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9(=EC=A0=90=EC=88=98=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=20=ED=8F=AC=ED=95=A8)=EA=B3=BC=20=EC=8B=A4=EC=A0=9C=20?= =?UTF-8?q?=EC=98=81=EC=83=81=20=EC=A0=9C=EB=AA=A9(oEmbed)=20=EB=AA=A8?= =?UTF-8?q?=EB=91=90.=20=EA=B8=B8=EC=9D=B4=EA=B0=80=20=EA=B0=99=EC=9D=80?= =?UTF-8?q?=20=EA=B2=B0=EA=B3=BC=EC=9D=98=20=EC=8B=A4=EC=A0=9C=20=EC=98=81?= =?UTF-8?q?=EC=83=81=EC=9D=B4=20'=EA=B4=91=20(Official=20MV)'=C2=B7'(Inst.?= =?UTF-8?q?)'=EC=9D=B4=EB=A9=B4=20matched=EB=A1=9C=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=EB=90=98=EB=8D=98=20=EA=B2=83.=20=ED=9A=8C=EA=B7=80=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8(=EB=A7=A4=EC=B9=AD=C2=B7reconfirm)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/server/src/collector/collector.test.ts | 25 +++++++++++++++++++-- apps/server/src/collector/match-youtube.ts | 8 +++---- apps/server/src/collector/score.ts | 11 ++++----- docs/12-decisions.md | 2 +- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/apps/server/src/collector/collector.test.ts b/apps/server/src/collector/collector.test.ts index 38ecef8..139dd10 100644 --- a/apps/server/src/collector/collector.test.ts +++ b/apps/server/src/collector/collector.test.ts @@ -52,8 +52,9 @@ test('scoring: title+artist confident whatever the length, MR/cover/MV/other mix expect(isConfident(scoreResult(song, yt('광 (Sleep Mix)', 'SG워너비', 3600), 0))).toBe(false); expect(isConfident(scoreResult(song, yt('광 (2021)', 'SG워너비', 300), 0))).toBe(false); expect(isConfident(scoreResult(song, { ...yt('광', 'SG워너비', 300), topic: false }, 0))).toBe(false); - // an MV with the same length still counts as before (score path) - expect(isConfident(scoreResult(song, yt('광 (Official MV)', 'SG워너비', 238), 0))).toBe(true); + // an MV or inst. is never the original, even with the same length + expect(isConfident(scoreResult(song, yt('광 (Official MV)', 'SG워너비', 237), 0))).toBe(false); + expect(isConfident(scoreResult(song, { ...yt('광 (Official MV)', 'SG워너비', 237), topic: false }, 0))).toBe(false); // a 38-second track or a 10-minute one under the same title is an intro, skit or megamix, not the song expect(isConfident(scoreResult(song, yt('광', 'SG워너비', 38), 0))).toBe(false); expect(isConfident(scoreResult(song, yt('광', 'SG워너비', 555), 0))).toBe(false); @@ -180,6 +181,26 @@ test('artist names learnt from confirmed songs (2+ songs) confirm waiting candid expect(st(farMv).youtube_status).toBe('candidate'); }); +test('YouTube matching: the actual video being an MV or inst. keeps the song a 후보 even with the same length', async () => { + const db = freshDb(); + const c = new Catalog(db); + const [mv] = c.upsert({ title: '광', artists: [{ name: 'SG워너비' }], durationSec: 237, source: 't', ref: '1' }); + const [inst] = c.upsert({ title: '내사람', artists: [{ name: 'SG워너비' }], durationSec: 300, source: 't', ref: '2' }); + const results: Record = { + 'SG워너비 광': [{ videoId: 'gwangmv0001', title: '광', artists: 'SG워너비', album: null, durationSec: 237 }], + 'SG워너비 내사람': [{ videoId: 'mineinst001', title: '내사람', artists: 'SG워너비', album: null, durationSec: 300 }], + }; + const titles: Record = { gwangmv0001: '광 (Official MV)', mineinst001: '내사람 (Inst.)' }; + const stats = await matchYoutube(db, { searchSongs: async (q) => results[q] ?? [] }, { delayMs: 0 }, async (id) => ({ state: 'ok', author: 'SG Wannabe', title: titles[id]! })); + expect(stats.matched).toBe(0); + const st = (id: number) => db.query<{ youtube_status: string }, [number]>('SELECT youtube_status FROM songs WHERE id = ?').get(id)!.youtube_status; + expect(st(mv!)).toBe('candidate'); + expect(st(inst!)).toBe('candidate'); + // reconfirm-youtube checks the same way + expect((await reconfirmCandidates(db, { delayMs: 0 }, async (id) => ({ state: 'ok', author: 'SG Wannabe', title: titles[id]! }))).matched).toBe(0); + expect([st(mv!), st(inst!)]).toEqual(['candidate', 'candidate']); +}); + function freshDb() { return openDb(tempDbPath()); } diff --git a/apps/server/src/collector/match-youtube.ts b/apps/server/src/collector/match-youtube.ts index 3861cdc..f88270a 100644 --- a/apps/server/src/collector/match-youtube.ts +++ b/apps/server/src/collector/match-youtube.ts @@ -43,12 +43,12 @@ function setAutoVideo(db: Database, id: number, status: 'matched' | 'candidate', } /** - * A result confirmed despite a length difference (title + artist) whose actual video turns out to be a music video, - * inst., live, another mix … (the YouTube title, not the search row): left as 후보. + * The actual video (its YouTube title, not the search row) turns out to be a music video, inst., live … — whatever the + * length — or, for a result confirmed despite a length difference, another mix/edit/year: left as 후보. */ function isOtherCut(c: Scored, videoTitle: string, songTitle: string): boolean { - if (!confirmedDespiteLength(c)) return false; - return (isVideoTitle(videoTitle) && !isVideoTitle(songTitle)) || (isJunkTitle(videoTitle) && !isJunkTitle(songTitle)) || namesOtherCut(videoTitle, songTitle); + if ((isVideoTitle(videoTitle) && !isVideoTitle(songTitle)) || (isJunkTitle(videoTitle) && !isJunkTitle(songTitle))) return true; + return confirmedDespiteLength(c) && namesOtherCut(videoTitle, songTitle); } async function searchRetry(ytm: Pick, query: string, job: Job | null): Promise { diff --git a/apps/server/src/collector/score.ts b/apps/server/src/collector/score.ts index cec142b..9c748e4 100644 --- a/apps/server/src/collector/score.ts +++ b/apps/server/src/collector/score.ts @@ -10,7 +10,7 @@ const BENIGN = /\b(?:radio edit|original|album|single|mono|stereo|remaster(?:ed) export const MAX_LENGTH_DIFF = 15; /** An artist that only sounds the same in the other script (디제이디오씨 ~ DJ DOC) confirms only this close. */ export const MAX_SOUND_LENGTH_DIFF = 8; -/** A music video or another cut of the song: never confirmed by title and artist alone when the length is off. */ +/** A music video, lyric video, stage clip …: never confirmed (unless the song's own title says so). */ /** Words of a different cut or recording: a mix, an edit, a dated re-recording … (only used when the length is off too). */ const CUT = /\b(?:mix|edit|ver|version|edition|demo|medley|reprise|session|take|cut|re-?recorded|piano|orchestra|strings|sleep|lo-?fi|extended|short|full|intro|outro)\b|\b(?:19|20)\d{2}\b|버전|믹스/gi; /** A remaster is the same recording: "(2021 Remastered)" is not a dated re-recording. */ @@ -100,16 +100,17 @@ export function scoreResult(song: { title: string; artist: string; durationSec: } /** - * Auto-confirm, any of: + * Never a cover/inst./live (junk) or a music video. Otherwise auto-confirm, any of: * - title + artist, whatever the length (a different take or a wrong Melon length), unless the result is a cover/inst./live - * (junk), a music video or not an official Topic track — and when the length is off, unless it names another mix/edit/year + * not an official Topic track — and when the length is off, unless it names another mix/edit/year * or the title is one artists reuse ("Intro"), or the result is under 90 seconds / over 7 minutes and twice the song's length; * - title + artist written in the other script that sounds the same, within MAX_SOUND_LENGTH_DIFF seconds; * - title + a close length (score 70+, e.g. without the artist), within MAX_LENGTH_DIFF seconds. */ export function isConfident(s: Scored): boolean { - if (!s.titleOk) return false; - const plain = !s.junk && !s.video && s.topic !== false; + // a music video, inst., live, cover … is never the original, whatever its length + if (!s.titleOk || s.junk || s.video) return false; + const plain = s.topic !== false; const lengthOff = s.lengthDiff !== null && s.lengthDiff > MAX_LENGTH_DIFF; if (s.artistOk && plain && !(lengthOff && (s.otherCut || s.genericTitle || s.oddLength))) return true; if (s.artistSound && plain && s.lengthDiff !== null && s.lengthDiff <= MAX_SOUND_LENGTH_DIFF) return true; diff --git a/docs/12-decisions.md b/docs/12-decisions.md index ce1d151..d780030 100644 --- a/docs/12-decisions.md +++ b/docs/12-decisions.md @@ -195,7 +195,7 @@ 2. 쌓인 후보는 `cli.ts reconfirm-youtube`로 저장된 검색 결과를 다시 비교했다(2,313곡 중 282곡 확정). 관리자 원곡 찾기 목록은 채널 이름 대신 실제 가수와 확정 안 된 이유를 보여 준다 ## 원곡 찾기 자동 확정 기준 2차 (2026-10-29, 사용자 확인) -1. **제목 + 가수가 맞으면 곡 길이가 달라도 확정**(다른 녹음·멜론 길이 오류). 단 길이가 15초 넘게 다를 때는 결과가 MV·가사 영상·inst.·라이브·커버이거나, 노래 제목에 없는 믹스/에디트/버전/연도(`(Sleep Mix)`, `(2021)`)가 붙었거나, 제목이 Intro·Outro처럼 흔하거나, 멜론은 보통 길이(90초 이상)인데 영상이 90초 미만이거나 7분 넘으면서 2배 넘게 길면(인트로·짧은 버전·메가믹스) 보류. 실제 영상 제목(oEmbed)도 같은 기준으로 한 번 더 본다. 리마스터는 같은 녹음. 공식 Topic이 아닌 일반 유튜브 영상은 길이 무시 안 함 +1. **제목 + 가수가 맞으면 곡 길이가 달라도 확정**(다른 녹음·멜론 길이 오류). 결과(검색 줄 제목이든 실제 영상 제목이든)가 MV·가사 영상·inst.·라이브·커버면 길이와 관계없이 확정하지 않는다. 길이가 15초 넘게 다를 때는 노래 제목에 없는 믹스/에디트/버전/연도(`(Sleep Mix)`, `(2021)`)가 붙었거나, 제목이 Intro·Outro처럼 흔하거나, 멜론은 보통 길이(90초 이상)인데 영상이 90초 미만이거나 7분 넘으면서 2배 넘게 길면(인트로·짧은 버전·메가믹스) 보류. 실제 영상 제목(oEmbed)도 같은 기준으로 한 번 더 본다. 리마스터는 같은 녹음. 공식 Topic이 아닌 일반 유튜브 영상은 길이 무시 안 함 2. **"한글 English" 표기 나눠 비교**: `북극성 Polaris`, `헤이즈 Heize`, `더 클래식 The Classic`(괄호 없이 띄어쓰기로 붙은 것). 제목을 나눠 맞춘 것은 가수도 맞을 때만 인정(다른 가수의 `작은 촛불 Little Flame`과 길이가 같다고 확정하지 않음). 뒤 영어가 몇 번째 곡을 뜻하면(`Part 2`, `I`, `Vol.1`) 나누지 않고, `/`·`+`로 여러 곡을 이은 메들리도 나누지 않음 3. **한글/영문 가수 이름은 발음으로 비교**(`collector/sound.ts`): 자음 뼈대가 같고, `Park Jung Hyun`처럼 로마자 한국 이름이면 모음 계열(아/에/오/이)도 같아야 함. 성이 뒤로 간 이름(`Bo Kyung Kim`), 알파벳 읽기(`DJ DOC`=디제이디오씨, `S.E.S.`=에스이에스) 포함. 발음으로만 맞은 곡은 제목이 같고 길이 차이 8초 이내일 때만 확정 4. **다른 문자 이름으로 다시 검색**: 결과에 그 가수의 곡이 하나도 없으면, 저장된 검색 결과에서 발음이 같은 다른 문자 이름(`DJ DOC`)을 찾아 `이름 제목`으로 한 번 더 검색(매일 원곡 찾기에 포함). 이 검색 결과는 그 가수 곡일 때만 확정. 이미 쌓인 후보는 `cli.ts research-youtube`(검색 방법별 한 번씩, `yt_research_`)