원곡찾기 후보 자동 확정: 가수·제목 비교 오류 수정(라틴 악센트 JAŸ-Z=JAY-Z, '및'·with 구분, 앞 The 무시, 'X JAPAN'을 x로 자르던 것), 'Radio Edit/Original Version'은 같은 녹음으로, 'ver.' 뒤 괄호에서 못 잡던 버전 표시 수정. 이미 확정된 곡에서 2곡 이상 확인된 한글/영문 가수 이름(태연=TAEYEON)을 배워 씀(레이블·컴필레이션 제외). 길이 15초 넘게 다르면 자동 확정 안 함. cli reconfirm-youtube(저장된 검색 결과로 다시 비교, --dry-run). 관리자 원곡 찾기 목록에 채널 이름 대신 실제 가수와 확정 안 된 이유('가수 다름: Ashiyane', '길이 40초 차이')
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,3 +25,11 @@ test('song match key is stable across spellings', () => {
|
||||
expect(songMatchKey('Last Scene (feat. 원슈타인)', '아이유')).toBe('lastscene|아이유');
|
||||
expect(songMatchKey('0+0', '한로로')).toBe('00|한로로');
|
||||
});
|
||||
|
||||
test('compare keys fold Latin accents and split 및 / with', () => {
|
||||
expect(keysOverlap(artistKeys('JAY-Z'), artistKeys('JAŸ-Z'))).toBe(true);
|
||||
expect(keysOverlap(artistKeys('Beyonce'), artistKeys('Beyoncé'))).toBe(true);
|
||||
expect(artistKeys('X JAPAN 및 YOSHIKI')).toEqual(expect.arrayContaining(['xjapan', 'yoshiki']));
|
||||
expect(keysOverlap(artistKeys('Human League'), artistKeys('The Human League'))).toBe(true);
|
||||
expect(titleKeys('が')).not.toContain('か'); // kana marks stay
|
||||
});
|
||||
|
||||
@@ -12,11 +12,19 @@ export function looseKey(s: string): string {
|
||||
.replace(/[^\p{L}\p{N}]+/gu, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparison key for YouTube matching only (not stored): like looseKey, but Latin letters lose their accents so
|
||||
* "JAŸ-Z" and "JAY-Z" or "Beyoncé" and "Beyonce" compare equal. Kana/Hangul marks are left alone.
|
||||
*/
|
||||
export function compareKey(s: string): string {
|
||||
return looseKey(s.normalize('NFD').replace(/(\p{Script=Latin})\p{M}+/gu, '$1').normalize('NFC'));
|
||||
}
|
||||
|
||||
/** Title variants: as is, without feat/prod tails, without any parenthesised part, and each parenthesised part alone. */
|
||||
export function titleKeys(title: string): string[] {
|
||||
const out = new Set<string>();
|
||||
const add = (s: string) => {
|
||||
const k = looseKey(s);
|
||||
const k = compareKey(s);
|
||||
if (k) out.add(k);
|
||||
};
|
||||
add(title);
|
||||
@@ -27,15 +35,17 @@ export function titleKeys(title: string): string[] {
|
||||
return [...out];
|
||||
}
|
||||
|
||||
/** Artist variants: split on , & / x and "(…)" so "RESCENE (리센느)" matches both names. */
|
||||
/** Artist variants: split on , & / x 및 with feat and "(…)" so "RESCENE (리센느)" matches both names. */
|
||||
export function artistKeys(artist: string): string[] {
|
||||
const out = new Set<string>();
|
||||
const parts = artist.split(/\s*(?:,|&|\/|\bx\b|\band\b|·|feat\.?)\s*/i);
|
||||
const parts = artist.split(/\s*(?:,|&|\/|×|\sx\s|\band\b|\s및\s|\bwith\b|\bvs\.?(?=\s)|·|\bfeat\.?|\bft\.)\s*/i);
|
||||
for (const p of [artist, ...parts]) {
|
||||
const k = looseKey(p);
|
||||
const k = compareKey(p);
|
||||
if (k) out.add(k);
|
||||
const noThe = compareKey(p.replace(/^\s*the\s+/i, ''));
|
||||
if (noThe) out.add(noThe);
|
||||
const inner = /^(.*?)\s*\(([^)]+)\)\s*$/.exec(p);
|
||||
if (inner) for (const q of [inner[1]!, inner[2]!]) if (looseKey(q)) out.add(looseKey(q));
|
||||
if (inner) for (const q of [inner[1]!, inner[2]!]) if (compareKey(q)) out.add(compareKey(q));
|
||||
}
|
||||
return [...out];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user