From b117a45c24664261ce5b30cc737f10253154522c Mon Sep 17 00:00:00 2001 From: Korbs Date: Thu, 27 Jun 2024 05:40:01 -0400 Subject: [PATCH] Add 1080p/4K/8K support and use best quality available --- src/pages/watch.astro | 507 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 496 insertions(+), 11 deletions(-) diff --git a/src/pages/watch.astro b/src/pages/watch.astro index fc27fa3..f521fdf 100644 --- a/src/pages/watch.astro +++ b/src/pages/watch.astro @@ -16,17 +16,502 @@ Astro.cookies.set("InlinePlayerId", SWV, { path: "/", sameSite: "strict", }); + +// Quality Check +const EightKCheck = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + '/latest_version?id=' + video.videoId + '&itag=571') +if (EightKCheck.status == 200) { + var EightK = true +} else { + var EightK = false +} + +const FourKCheck = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + '/latest_version?id=' + video.videoId + '&itag=313') +if (FourKCheck.status == 200) { + var FourK = true +} else { + var FourK = false +} + +const TenEightyCheck = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + '/latest_version?id=' + video.videoId + '&itag=137') +if (TenEightyCheck.status == 200) { + var TenEighty = true +} else { + var TenEighty = false +} + +const ThreeSixtyCheck = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + '/latest_version?id=' + video.videoId + '&itag=134') +if (ThreeSixtyCheck.status == 200) {var ThreeSixty = true} + +if (EightK === true) { // 571 + var Quality = '571' +} else if (FourK === true) { // 313 + var Quality = '313' +} else if (TenEighty === true) { // 137 + var Quality = '137' +} else if (ThreeSixty === true) { // 134 + var Quality = '134' +} --- -