곡 제목 특수문자(' &) 깨짐 수정: 멜론 차트가 16진수 엔티티를 못 풀고 norabose는 아예 안 풀던 것 → decodeEntities 한 곳에서(차트 파싱·카탈로그 저장), 이미 저장된 곡·차트 기록은 cli fix-text로 복구(키 다시 계산, 원곡 찾기 다시 시도, 깨진 키로 생긴 중복은 오래된 곡으로 합치기). 곡 합치기가 차트 기록도 옮기도록
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/** Writes into the song catalog (docs/07). Idempotent: re-running an import never duplicates songs. */
|
||||
import type { Database } from 'bun:sqlite';
|
||||
import { songMatchKey } from '@mq/shared';
|
||||
import { decodeEntities } from './text';
|
||||
|
||||
export interface SongInput {
|
||||
melonId?: number | null;
|
||||
@@ -31,7 +32,9 @@ export class Catalog {
|
||||
}
|
||||
|
||||
/** Finds the song by Melon id, else by match key; creates it when new. Returns [id, created]. */
|
||||
upsert(s: SongInput, now = Date.now()): [number, boolean] {
|
||||
upsert(input: SongInput, now = Date.now()): [number, boolean] {
|
||||
// Sources hand us HTML-escaped text now and then (norabose `Salty & Sweet`): store what people read.
|
||||
const s = { ...input, title: decodeEntities(input.title), artists: input.artists.map((a) => ({ ...a, name: decodeEntities(a.name) })) };
|
||||
return this.db.transaction((): [number, boolean] => {
|
||||
const artist = s.artists.map((a) => a.name).join(', ');
|
||||
const key = songMatchKey(s.title, artist);
|
||||
|
||||
Reference in New Issue
Block a user