재생목록 검토: 서버 DB 곡으로 바꾼 스포티파이 곡도 그 영상의 다른 사이트 재생을 확인(막혔으면 재생 불가 → 엑셀의 빠진 곡) — DB 상태만 믿고 건너뛰던 것, 회귀 테스트. 재생목록으로 엑셀 만들기: 검토 상황 조회가 한 번 실패하면 다음 조회가 없어 '검토 중'에 멈추던 것 — 실패해도 점점 느리게 계속 묻고(연결 다시 시도 중 표시, 알림은 처음 한 번), 작업이 없어졌으면(404) 실패로 끝냄. e2e: 첫 조회 502 뒤에도 엑셀 받기까지

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-03 23:24:18 +09:00
parent 70edadfe36
commit 4e2b81c224
4 changed files with 60 additions and 11 deletions

View File

@@ -2,7 +2,7 @@
import { afterEach, expect, test } from 'bun:test';
import type { ServerMessage } from '@mq/shared';
import { Catalog } from './collector/catalog';
import { cleanVideoTitle } from './quizzes/playlist';
import { cleanVideoTitle, getImportJob, startImport } from './quizzes/playlist';
import { Client, TEST_SUPERADMINS, api, boot, discordLogin, guest, sleep } from './test-utils';
type Msg<T extends ServerMessage['t']> = Extract<ServerMessage, { t: T }>;
@@ -325,3 +325,25 @@ test('영상 제목 정리: 가수 - 제목 / 가수 \'제목\' / 토픽은 그
expect(cleanVideoTitle('Ditto', 'NewJeans - Topic')).toEqual({ title: 'Ditto', artist: 'NewJeans', guessed: false });
expect(cleanVideoTitle('밤편지 (Official MV)', '아이유 공식')).toEqual({ title: '밤편지', artist: '아이유', guessed: true });
});
test('플레이리스트 가져오기: 서버 DB 곡으로 바꾼 스포티파이 곡도 그 영상이 다른 사이트에서 재생되는지 확인 (막혔으면 재생 불가)', async () => {
start();
const embedded: string[] = [];
const job = await startImport(
{
db: s.db,
lavalink: { url: 'http://lavalink.test', password: 'pw' },
fetchImpl: (async () =>
Response.json({ loadType: 'playlist', data: { info: { name: 'p' }, tracks: [{ info: { identifier: 'sp9', title: '좋은 날', author: '아이유', length: 230000, sourceName: 'spotify' } }] } })) as unknown as typeof fetch,
search: async () => [],
embed: async (v) => (embedded.push(v), { state: 'noembed' }),
delayMs: 0,
},
'owner',
'https://open.spotify.com/playlist/y',
);
if (typeof job === 'string') throw new Error(job);
for (let i = 0; i < 100 && getImportJob(job.id, 'owner')!.status === 'running'; i++) await sleep(5);
expect(embedded).toEqual(['goodday0001']);
expect(getImportJob(job.id, 'owner')!.rows).toMatchObject([{ status: 'blocked', videoId: 'goodday0001', note: '다른 사이트 재생이 막힌 영상' }]);
});

View File

@@ -134,14 +134,19 @@ async function runImport(d: ImportDeps, job: ImportJob, tracks: LavalinkTrack[])
const named = yt ? cleanVideoTitle(t.title, t.author) : { title: t.title, artist: t.author, guessed: false };
const row: ImportRow = { n: i + 1, source: { title: t.title, artist: t.author }, title: named.title, artist: named.artist, durationSec: dur, videoId: null, songId: null, status: 'missing', note: '' };
const dbSong = (yt ? byVideo.get(t.identifier) : null) ?? byKey.get(songMatchKey(named.title, named.artist));
// the video must play on other sites, the DB song's own video too (the DB state may be old)
const playable = async (videoId: string) => {
const e = await d.embed(videoId);
if (e.state !== 'ok') Object.assign(row, { status: 'blocked', note: e.state === 'noembed' ? '다른 사이트 재생이 막힌 영상' : e.state === 'dead' ? '없는 영상' : '영상 확인 실패' });
};
if (yt) {
row.videoId = t.identifier;
if (dbSong) Object.assign(row, { songId: dbSong.id, title: dbSong.title, artist: dbSong.artist, status: 'db', note: '서버 DB 곡 (플레이리스트 영상 사용)' });
else Object.assign(row, { status: 'video', note: named.guessed ? '제목·가수 확인 필요 (영상 제목 형식이 달라 채널 이름을 가수로 씀)' : '' });
const e = await d.embed(t.identifier);
if (e.state !== 'ok') Object.assign(row, { status: 'blocked', note: e.state === 'noembed' ? '다른 사이트 재생이 막힌 영상' : e.state === 'dead' ? '없는 영상' : '영상 확인 실패' });
await playable(t.identifier);
} else if (dbSong?.youtube_id && dbSong.youtube_status === 'matched') {
Object.assign(row, { songId: dbSong.id, videoId: dbSong.youtube_id, title: dbSong.title, artist: dbSong.artist, durationSec: dbSong.duration_sec ?? dur, status: 'db', note: '서버 DB 곡' });
await playable(dbSong.youtube_id);
} else {
// Spotify (or any non-YouTube source): find the official audio like 원곡 찾기
let results: YtmSong[] = [];