원곡찾기: 노래 제목에 보류 표시가 하나라도 있으면(Live Wire의 live, 거북선 Remix의 remix) inst.·커버·MV 검사가 통째로 꺼지던 것 — 표시를 하나씩 세어 노래 제목에 있는 표시만 그 개수만큼 예외('Remix Version'=remix 하나). 검색 줄 제목·실제 영상 제목 모두, 매칭·reconfirm 회귀 테스트

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-29 11:13:26 +09:00
parent 9ab3c9258e
commit 8fc62458f3
4 changed files with 68 additions and 13 deletions

View File

@@ -81,6 +81,36 @@ test('scoring: accents, 및, "Radio Edit Version" and the length limit', () => {
expect(notConfidentReasons(other)).toEqual(['가수 다름: Ashiyane']);
});
test('a song whose own title has a mark ("Live Wire", "거북선 Remix") still keeps out an added inst./cover/MV', async () => {
const yt = (title: string, artists: string, durationSec: number): YtmSong => ({ videoId: 'x', title, artists, album: null, durationSec });
const wire = { title: 'Live Wire', artist: '서태지', durationSec: 242 };
const turtle = { title: '거북선 Remix', artist: '팔로알토', durationSec: 279 };
expect(isConfident(scoreResult(wire, yt('Live Wire', '서태지', 242), 0))).toBe(true);
for (const t of ['Live Wire (Inst.)', 'Live Wire (Cover)', 'Live Wire (Official MV)', 'Live Wire (Live)']) expect([t, isConfident(scoreResult(wire, yt(t, '서태지', 242), 0))]).toEqual([t, false]);
expect(isConfident(scoreResult(turtle, yt('거북선 Remix Version', '팔로알토', 281), 0))).toBe(true);
expect(isConfident(scoreResult(turtle, yt('거북선 Remix (Inst.)', '팔로알토', 279), 0))).toBe(false);
// the same through matching and reconfirm-youtube, when only the actual video's title shows it
const db = freshDb();
const c = new Catalog(db);
const add = (title: string, artist: string, dur: number, ref: string) => c.upsert({ title, artists: [{ name: artist }], durationSec: dur, source: 't', ref })[0]!;
const ids = { wire: add('Live Wire', '서태지', 242, '1'), wireInst: add('Live Wire 2', '서태지', 242, '2'), turtle: add('거북선 Remix', '팔로알토', 279, '3'), turtleInst: add('거북선 Remix 2', '팔로알토', 279, '4') };
const results: Record<string, YtmSong[]> = {
'서태지 Live Wire': [{ videoId: 'wire0000001', title: 'Live Wire', artists: '서태지', album: null, durationSec: 242 }],
'서태지 Live Wire 2': [{ videoId: 'wireinst001', title: 'Live Wire 2', artists: '서태지', album: null, durationSec: 242 }],
'팔로알토 거북선 Remix': [{ videoId: 'turtle00001', title: '거북선 Remix Version', artists: '팔로알토', album: null, durationSec: 281 }],
'팔로알토 거북선 Remix 2': [{ videoId: 'turtleinst1', title: '거북선 Remix 2', artists: '팔로알토', album: null, durationSec: 279 }],
};
const titles: Record<string, string> = { wire0000001: 'Live Wire', wireinst001: 'Live Wire 2 (Inst.)', turtle00001: '거북선 Remix Version', turtleinst1: '거북선 Remix 2 (Inst.)' };
const embed = async (id: string) => ({ state: 'ok' as const, author: 'x', title: titles[id]! });
await matchYoutube(db, { searchSongs: async (q) => results[q] ?? [] }, { delayMs: 0 }, embed);
const st = (id: number) => db.query<{ youtube_status: string }, [number]>('SELECT youtube_status FROM songs WHERE id = ?').get(id)!.youtube_status;
expect([st(ids.wire), st(ids.wireInst), st(ids.turtle), st(ids.turtleInst)]).toEqual(['matched', 'candidate', 'matched', 'candidate']);
db.query("UPDATE songs SET youtube_status = 'candidate', youtube_source = 'norabose' WHERE id IN (?, ?)").run(ids.wire, ids.turtle);
await reconfirmCandidates(db, { delayMs: 0 }, embed);
expect([st(ids.wire), st(ids.wireInst), st(ids.turtle), st(ids.turtleInst)]).toEqual(['matched', 'candidate', 'matched', 'candidate']);
});
test('Hangul and Latin artist names that sound the same', () => {
const same = [
['디제이디오씨', 'DJ DOC'], ['에스이에스', 'S.E.S.'], ['플라이투더스카이', 'Fly to the Sky'], ['조규찬', 'Cho Kyu Chan'], ['강타', 'KANGTA'],

View File

@@ -6,7 +6,7 @@
import type { Database } from 'bun:sqlite';
import { Job, sleep } from './catalog';
import { checkEmbed } from './oembed';
import { confirmedDespiteLength, isConfident, isJunkTitle, isVideoTitle, namesOtherCut, scoreResult, type Scored } from './score';
import { addsJunk, addsVideo, confirmedDespiteLength, isConfident, namesOtherCut, scoreResult, type Scored } from './score';
import { learnArtistAliases } from './artist-aliases';
import { otherScriptNames } from './other-names';
import { CookieError, type YtMusic, type YtmSong } from './ytmusic';
@@ -47,7 +47,7 @@ function setAutoVideo(db: Database, id: number, status: 'matched' | 'candidate',
* 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 ((isVideoTitle(videoTitle) && !isVideoTitle(songTitle)) || (isJunkTitle(videoTitle) && !isJunkTitle(songTitle))) return true;
if (addsVideo(videoTitle, songTitle) || addsJunk(videoTitle, songTitle)) return true;
return confirmedDespiteLength(c) && namesOtherCut(videoTitle, songTitle);
}

View File

@@ -3,7 +3,9 @@ import { artistKeys, artistParts, keysOverlap, titleKeys, titleRunKeys } from '@
import { soundsLike } from './sound';
import type { YtmSong } from './ytmusic';
const JUNK = /\b(inst|instrumental|mr|karaoke|cover|remix|sped ?up|slowed|live|ver|version|acoustic|made famous by|in the style of|originally performed|tribute)\b|노래방|커버|라이브|반주/i;
const JUNK = /\b(?:inst|instrumental|mr|karaoke|cover|remix|sped ?up|slowed|live|ver|version|acoustic|made famous by|in the style of|originally performed|tribute)\b|노래방|커버|라이브|반주/gi;
/** "Remix Version", "Live Ver." name one take (remix, live), not two marks. */
const TAG_VERSION = /\b(inst|instrumental|mr|karaoke|cover|remix|live|acoustic)\s*(?:ver\.?|version)(?=\W|$)/gi;
/** "Radio Edit Version", "Original Version", "7\" Version" are the same recording, not a different take. */
const BENIGN = /\b(?:radio edit|original|album|single|mono|stereo|remaster(?:ed)?)\s*(?:ver\.?|version)?|\d{1,2}"\s*(?:ver\.?|version)|\bedit\b/gi;
/** Without the artist, a title only confirms with a length this close (when both lengths are known). */
@@ -17,7 +19,7 @@ const CUT = /\b(?:mix|edit|ver|version|edition|demo|medley|reprise|session|take|
const REMASTER = /\b(?:(?:19|20)\d{2}\s+)?remaster(?:ed)?(?:\s+(?:19|20)\d{2})?\b|\bradio edit\b|\b(?:original|album|single)\s+(?:ver\.?|version)\b/gi;
/** Titles an artist reuses album after album ("Intro"): the same title says nothing when the length is off. */
const GENERIC_TITLE = /^\s*(?:intro|outro|interlude|skit|prologue|epilogue|opening|ending|theme|bonus\s+track|hidden\s+track)\s*\d*\s*$/i;
const VIDEO = /\b(?:m\/?v|music\s+video|official\s+video|performance\s+video|lyrics?\s+video|visualizer|teaser|dance\s+practice|special\s+clip|full\s+ver)\b|뮤직\s*비디오|뮤비|직캠/i;
const VIDEO = /\b(?:m\/?v|music\s+video|official\s+video|performance\s+video|lyrics?\s+video|visualizer|teaser|dance\s+practice|special\s+clip|full\s+ver)\b|뮤직\s*비디오|뮤비|직캠/gi;
/** Song-side artist key → YouTube-side keys learnt from already confirmed songs ("태연" → "taeyeon"). */
export type ArtistAliases = Map<string, Set<string>>;
@@ -41,13 +43,36 @@ export interface Scored extends YtmSong {
lengthDiff: number | null;
}
export function isJunkTitle(title: string): boolean {
return JUNK.test(title.replace(BENIGN, ' '));
/** Each mark the regex finds in the title, counted ("instrumental" = "inst", "version" = "ver"). */
function marks(re: RegExp, title: string): Map<string, number> {
const out = new Map<string, number>();
for (const m of title.match(re) ?? []) {
const k = m.toLowerCase().replace(/\s+/g, ' ').replace(/^instrumental$/, 'inst').replace(/^version$/, 'ver').replace(/^m\/v$/, 'mv');
out.set(k, (out.get(k) ?? 0) + 1);
}
return out;
}
/** A music video, lyric video, live stage … or a cover/inst./remix (isJunkTitle): not the plain recording. */
export function isVideoTitle(title: string): boolean {
return VIDEO.test(title);
/**
* The result adds a mark the song's own title doesn't have: each mark is matched against the song's ("Live Wire" lets
* one "live" through, not "(Inst.)" or a second "Live").
*/
function addsMark(re: RegExp, resultTitle: string, songTitle: string): boolean {
const own = marks(re, songTitle);
for (const [k, n] of marks(re, resultTitle)) if (n > (own.get(k) ?? 0)) return true;
return false;
}
const junkText = (t: string) => t.replace(BENIGN, ' ').replace(TAG_VERSION, '$1');
/** The result is a cover, inst., MR, live, remix, another version … that the song's own title doesn't say. */
export function addsJunk(resultTitle: string, songTitle: string): boolean {
return addsMark(JUNK, junkText(resultTitle), junkText(songTitle));
}
/** The result is a music video, lyric video, stage clip … that the song's own title doesn't say. */
export function addsVideo(resultTitle: string, songTitle: string): boolean {
return addsMark(VIDEO, resultTitle, songTitle);
}
/** Some name of the song's artist sounds like some name of the result's, across Hangul and Latin. */
@@ -90,10 +115,10 @@ export function scoreResult(song: { title: string; artist: string; durationSec:
if (rank === 0) score += 5;
// Plain YouTube fallback: only official Topic art tracks are trusted; MVs, lyric videos and fan uploads are scored down.
if (r.topic === false) score -= 25;
// Junk words only count when the original title doesn't have them (a real "Remix" song stays fine).
const junk = isJunkTitle(r.title) && !isJunkTitle(song.title);
// Junk words only count beyond the ones in the original title (a real "Remix" song stays fine, its "(Inst.)" doesn't).
const junk = addsJunk(r.title, song.title);
if (junk) score -= 40;
const video = isVideoTitle(r.title) && !isVideoTitle(song.title);
const video = addsVideo(r.title, song.title);
const otherCut = namesOtherCut(r.title, song.title);
const oddLength = !!song.durationSec && song.durationSec >= 90 && !!r.durationSec && (r.durationSec < 90 || (r.durationSec > 420 && r.durationSec > 2 * song.durationSec));
return { ...r, score, titleOk, artistOk, artistSound, junk, video, otherCut, genericTitle: GENERIC_TITLE.test(song.title), oddLength, lengthDiff };

View File

@@ -195,7 +195,7 @@
2. 쌓인 후보는 `cli.ts reconfirm-youtube`로 저장된 검색 결과를 다시 비교했다(2,313곡 중 282곡 확정). 관리자 원곡 찾기 목록은 채널 이름 대신 실제 가수와 확정 안 된 이유를 보여 준다
## 원곡 찾기 자동 확정 기준 2차 (2026-10-29, 사용자 확인)
1. **제목 + 가수가 맞으면 곡 길이가 달라도 확정**(다른 녹음·멜론 길이 오류). 결과(검색 줄 제목이든 실제 영상 제목이든)가 MV·가사 영상·inst.·라이브·커버면 길이와 관계없이 확정하지 않는다. 길이가 15초 넘게 다를 때는 노래 제목에 없는 믹스/에디트/버전/연도(`(Sleep Mix)`, `(2021)`)가 붙었거나, 제목이 Intro·Outro처럼 흔하거나, 멜론은 보통 길이(90초 이상)인데 영상이 90초 미만이거나 7분 넘으면서 2배 넘게 길면(인트로·짧은 버전·메가믹스) 보류. 실제 영상 제목(oEmbed)도 같은 기준으로 한 번 더 본다. 리마스터는 같은 녹음. 공식 Topic이 아닌 일반 유튜브 영상은 길이 무시 안 함
1. **제목 + 가수가 맞으면 곡 길이가 달라도 확정**(다른 녹음·멜론 길이 오류). 결과(검색 줄 제목이든 실제 영상 제목이든)가 MV·가사 영상·inst.·라이브·커버면 길이와 관계없이 확정하지 않는다. 노래 제목에 있는 표시는 그 표시만 그 개수만큼 예외(`Live Wire`는 live 하나만 허용, `(Inst.)`·`(Cover)`·두 번째 Live는 보류, `Remix Version`=remix 하나). 길이가 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_<source>`)