From cee550f063e6eaf7d2595deecc100f4f263b6507 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Tue, 3 Nov 2026 21:10:13 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=84=A0=EB=8B=A4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=88=98=20=EC=9E=90=EB=8F=99:=20=EC=9C=A0?= =?UTF-8?q?=ED=8A=9C=EB=B8=8C=20=EB=AE=A4=EC=A7=81=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=EC=97=90=20=EB=A7=81=ED=81=AC=ED=95=9C=20=EC=98=81=EC=83=81?= =?UTF-8?q?=EC=9D=B4=20=EC=95=84=EC=98=88=20=EC=97=86=EC=9C=BC=EB=A9=B4(?= =?UTF-8?q?=EB=B9=88=20=EC=9D=91=EB=8B=B5=C2=B7=ED=98=95=EC=8B=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD)=20=EC=A7=9D=EC=9D=84=20=EB=AA=A8=EB=A5=B4?= =?UTF-8?q?=EB=8A=94=20=EA=B2=83=EC=9D=B4=EB=AF=80=EB=A1=9C=20'=ED=86=A0?= =?UTF-8?q?=ED=94=BD=20=EC=97=86=EC=9D=8C'=EC=9C=BC=EB=A1=9C=20=ED=99=95?= =?UTF-8?q?=EC=A0=95=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=EB=A1=9C=20=EB=91=A0=20=E2=80=94=20=EA=B7=B8=20?= =?UTF-8?q?=EC=98=81=EC=83=81=20=EC=A1=B0=ED=9A=8C=EC=88=98=EB=A7=8C=20don?= =?UTF-8?q?e=EC=9C=BC=EB=A1=9C=20=EC=A0=80=EC=9E=A5=ED=95=98=EB=8D=98=20?= =?UTF-8?q?=EA=B2=83.=20=ED=9A=8C=EA=B7=80=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= 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/duel-views.test.ts | 6 +++++- apps/server/src/quizzes/duel-views.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/server/src/duel-views.test.ts b/apps/server/src/duel-views.test.ts index 96154bf..792ac16 100644 --- a/apps/server/src/duel-views.test.ts +++ b/apps/server/src/duel-views.test.ts @@ -68,6 +68,10 @@ test('fetchDuelViews: either half may be linked; a song with one half keeps that expect(mvOnly).toMatchObject({ topicId: null, mvId: 'onlyMV00001', mvViews: 20 }); // any other upload without a 토픽 pair: that video's views expect(await fetchDuelViews('fanUpload01', src, 1)).toMatchObject({ topicId: null, mvId: 'fanUpload01', mvViews: 7 }); + // signed in but the video is not in the answer (empty or changed response): unknown, not "토픽 없음" + const empty = { ...src, songPair: async () => parseSongPair(watch([]), 'lilacMV0001') }; + await expect(fetchDuelViews('lilacMV0001', empty, 1)).rejects.toThrow('곡 정보를 찾지 못했어요'); + expect(src.calls.filter((c) => c === 'views lilacMV0001')).toHaveLength(2); // 비고 const it = (viewsAuto: DuelViews | null, views: number | null = 1, fromFile = true) => duelViewsNote({ views, viewsAuto, fromFile }); expect(it(both as DuelViews)).toBeNull(); @@ -84,7 +88,7 @@ test('youtubeViewCount: the player count, else the watch page count, else an err expect(await youtubeViewCount('v7bnOxV4jAc', fake({ videoDetails: { videoId: 'v7bnOxV4jAc', viewCount: '120456684' } }, ''))).toBe(120456684); const page = '{"videoViewCountRenderer":{"viewCount":{"simpleText":"조회수 120,456,684회"}}}'; expect(await youtubeViewCount('v7bnOxV4jAc', fake({ playabilityStatus: { status: 'LOGIN_REQUIRED' } }, page))).toBe(120456684); - expect(youtubeViewCount('v7bnOxV4jAc', fake({}, '{}'))).rejects.toThrow('조회수를 찾지 못했어요'); + await expect(youtubeViewCount('v7bnOxV4jAc', fake({}, '{}'))).rejects.toThrow('조회수를 찾지 못했어요'); }); // ------------------------------------------------------------------ upload → fetch → editor diff --git a/apps/server/src/quizzes/duel-views.ts b/apps/server/src/quizzes/duel-views.ts index 28d2d8d..815eae4 100644 --- a/apps/server/src/quizzes/duel-views.ts +++ b/apps/server/src/quizzes/duel-views.ts @@ -20,6 +20,8 @@ const UA = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Geck /** The linked video may be either half: a 토픽 pairs with its MV, anything else (MV, other upload) with its 토픽. */ export async function fetchDuelViews(videoId: string, src: ViewsSource, now = Date.now()): Promise { const pair = await src.songPair(videoId); + // the video is not in the answer at all: nothing is known about its pair, so this is no "토픽 없음" + if (!pair.type) throw new Error('유튜브 뮤직에서 이 영상의 곡 정보를 찾지 못했어요'); const selfTopic = pair.type === TOPIC; const topicId = selfTopic ? videoId : pair.other?.type === TOPIC ? pair.other.videoId : null; const mvId = !selfTopic ? videoId : pair.other && pair.other.type !== TOPIC ? pair.other.videoId : null;