feat(network): request-throttle controls to avoid YouTube rate-limiting
Re-implements the sleepRequests/sleepInterval/maxSleepInterval feature (--sleep-requests / --sleep-interval / --max-sleep-interval) from the stale feat/binary-management-and-library-scale branch, ported onto current main's structure (zod settingsSchema, decomposed NetworkCard). All default to 0/off, preserving current behaviour. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,46 @@ describe('network options', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// --- Request throttle: sleep-requests / sleep-interval ----------------------
|
||||
|
||||
describe('throttle options', () => {
|
||||
it('emits no sleep flags when all throttle values are 0/unset', () => {
|
||||
const argv = build(opts(), dlo(), NO_ACCESS)
|
||||
expect(argv).not.toContain('--sleep-requests')
|
||||
expect(argv).not.toContain('--sleep-interval')
|
||||
expect(argv).not.toContain('--max-sleep-interval')
|
||||
})
|
||||
|
||||
it('emits --sleep-requests when sleepRequests > 0', () => {
|
||||
const argv = build(opts(), dlo(), { ...NO_ACCESS, sleepRequests: 3 })
|
||||
expect(hasSeq(argv, '--sleep-requests', '3')).toBe(true)
|
||||
})
|
||||
|
||||
it('emits --sleep-interval when sleepInterval > 0', () => {
|
||||
const argv = build(opts(), dlo(), { ...NO_ACCESS, sleepInterval: 5 })
|
||||
expect(hasSeq(argv, '--sleep-interval', '5')).toBe(true)
|
||||
expect(argv).not.toContain('--max-sleep-interval')
|
||||
})
|
||||
|
||||
it('emits --max-sleep-interval only when it exceeds a non-zero sleepInterval', () => {
|
||||
const argv = build(opts(), dlo(), { ...NO_ACCESS, sleepInterval: 5, maxSleepInterval: 10 })
|
||||
expect(hasSeq(argv, '--sleep-interval', '5')).toBe(true)
|
||||
expect(hasSeq(argv, '--max-sleep-interval', '10')).toBe(true)
|
||||
})
|
||||
|
||||
it('drops --max-sleep-interval when sleepInterval is 0 (yt-dlp needs the min)', () => {
|
||||
const argv = build(opts(), dlo(), { ...NO_ACCESS, sleepInterval: 0, maxSleepInterval: 10 })
|
||||
expect(argv).not.toContain('--sleep-interval')
|
||||
expect(argv).not.toContain('--max-sleep-interval')
|
||||
})
|
||||
|
||||
it('drops --max-sleep-interval when it is not above the min', () => {
|
||||
const argv = build(opts(), dlo(), { ...NO_ACCESS, sleepInterval: 8, maxSleepInterval: 5 })
|
||||
expect(hasSeq(argv, '--sleep-interval', '8')).toBe(true)
|
||||
expect(argv).not.toContain('--max-sleep-interval')
|
||||
})
|
||||
})
|
||||
|
||||
// --- Cookies: browser store vs. sign-in window's exported file --------------
|
||||
|
||||
describe('cookies', () => {
|
||||
|
||||
Reference in New Issue
Block a user