유튜브 뮤직 쿠키 끊김 줄이기: 429가 한 번이라도 나오면 쿠키를 쓰는 모든 작업(자동 갱신·로그인 확인·원곡 찾기 검색·조회수 짝 찾기·연령제한 음원 받기)이 3시간 쉼 — <쿠키 파일>.cooldown에 끝 시각을 적어 서버와 수집 CLI가 함께 봄(RateLimited). 원곡 찾기는 429에 1분 뒤 다시 묻지 않고 바로 멈춤(stopped), 갱신은 10분 뒤 재시도 대신 쉼이 끝날 때까지 기다림(새 쿠키 파일은 바로 확인). 검색 간격 2초 → 5초, 조회수 곡 간격 0.5초 → 2초. 다른 사이트 요청에서 복사해 __Secure-3P*만 있는 쿠키도 받음: SAPISID를 같은 값인 __Secure-3PAPISID로 읽을 때 채우고, 로그인 값은 __Secure-1PSID/3PSID 중 하나면 됨. 11/03 08:10 원곡 찾기 567곡 직후 갱신 429 → 401로 세션이 끝난 것. 회귀 테스트(채우기·갱신·검색·키퍼·원곡 찾기·연령제한·조회수), docs 08·09·12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** 이지선다 조회수 자동: 토픽 ↔ MV pair from a YouTube Music watch response, view counts, and the upload → fetch → editor flow. */
|
||||
import { afterEach, expect, test } from 'bun:test';
|
||||
import { duelViewsNote, type DuelViews, type QuizItem } from '@mq/shared';
|
||||
import { CookieError, parseSongPair, type SongPair } from './collector/ytmusic';
|
||||
import { CookieError, parseSongPair, RateLimited, type SongPair } from './collector/ytmusic';
|
||||
import { fetchDuelViews, youtubeViewCount, type ViewsSource } from './quizzes/duel-views';
|
||||
import { TEST_SUPERADMINS, api, boot, discordLogin } from './test-utils';
|
||||
|
||||
@@ -213,3 +213,20 @@ test('signed out (or a song that cannot be read): songs are marked failed with t
|
||||
expect((await call('POST', `/quizzes/${normal}/views`, {})).res.status).toBe(400);
|
||||
expect((await call('GET', `/quizzes/${normal}`)).body.quiz.items[0]).toMatchObject({ views: null, viewsAuto: null });
|
||||
});
|
||||
|
||||
test('429 from YouTube Music: every waiting song stops with the pause in its note (no retry)', async () => {
|
||||
let n = 0;
|
||||
const src = fakeSource({}, {});
|
||||
const { call, settled } = await setup(async () => ({
|
||||
...src,
|
||||
songPair: async () => {
|
||||
n++;
|
||||
throw new RateLimited(Date.parse('2026-11-03T15:00:00Z'));
|
||||
},
|
||||
}));
|
||||
const id = (await call('POST', '/quizzes/file', { name: '429', kind: 'duel', items: [row('aaaaaaaaaa1', '하나'), row('aaaaaaaaaa2', '둘')] })).body.id as number;
|
||||
const items = await settled(id);
|
||||
expect(n).toBe(1);
|
||||
expect(items.map((i) => i.viewsAuto?.state)).toEqual(['failed', 'failed']);
|
||||
expect(duelViewsNote(items[1]!)).toContain('00:00까지 쉬어요');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user