From 0d46a9a0995fbb919f43c33097b6bdee8332f93f Mon Sep 17 00:00:00 2001 From: Anthony GAEREMYNCK <1@anthony.sh> Date: Tue, 11 Aug 2026 15:18:35 +0200 Subject: [PATCH] feat: add 4K and 2K quality tiers --- src/lib/__tests__/ytdlp-probe.test.ts | 21 +++++++++++++++++++++ src/lib/ytdlp-options.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/lib/__tests__/ytdlp-probe.test.ts b/src/lib/__tests__/ytdlp-probe.test.ts index b696ec5..6b77a9e 100644 --- a/src/lib/__tests__/ytdlp-probe.test.ts +++ b/src/lib/__tests__/ytdlp-probe.test.ts @@ -39,6 +39,27 @@ describe('parseProbeOutput', () => { expect(result.subtitleLangs).toEqual(['fr', 'en', 'es']) }) + it('includes 4K and 2K when the source tops out at 4K', () => { + const result = parseProbeOutput(json({ + formats: [ + { height: 1080, vcodec: 'avc1' }, + { height: 1440, vcodec: 'avc1' }, + { height: 2160, vcodec: 'avc1' }, + ], + })) + expect(result.availableQualities).toEqual(['best', '2160p', '1440p', '1080p', '720p', '480p', '360p']) + }) + + it('includes 2K but excludes 4K when the source tops out below 4K', () => { + const result = parseProbeOutput(json({ + formats: [ + { height: 1080, vcodec: 'avc1' }, + { height: 1440, vcodec: 'avc1' }, + ], + })) + expect(result.availableQualities).toEqual(['best', '1440p', '1080p', '720p', '480p', '360p']) + }) + it('caps available qualities to the max height found', () => { const result = parseProbeOutput(json({ formats: [ diff --git a/src/lib/ytdlp-options.ts b/src/lib/ytdlp-options.ts index 7e0a90d..1c19d2b 100644 --- a/src/lib/ytdlp-options.ts +++ b/src/lib/ytdlp-options.ts @@ -1,3 +1,3 @@ export const FORMATS = ['mp4', 'mp3', 'webm', 'mkv'] as const -export const QUALITIES = ['best', '1080p', '720p', '480p', '360p'] as const +export const QUALITIES = ['best', '2160p', '1440p', '1080p', '720p', '480p', '360p'] as const export const AUDIO_QUALITIES = ['best', '192', '128'] as const