From ebd89acf79ba8501453971c0dff116bdab219a26 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Wed, 1 Jan 2025 02:16:40 -0300 Subject: [PATCH] fix(hls): add missing scheme to m3u8 list --- src/invidious/routes/api/manifest.cr | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.cr index 4e2a1b50..2c6f74b7 100644 --- a/src/invidious/routes/api/manifest.cr +++ b/src/invidious/routes/api/manifest.cr @@ -221,10 +221,16 @@ module Invidious::Routes::API::Manifest proxy = Invidious::HttpServer::Utils.get_external_proxy - if !proxy.empty? - "#{proxy}/videoplayback?#{raw_params}" + if CONFIG.https_only + scheme = "https://" else - "#{env.request.headers["Host"]}/videoplayback?#{raw_params}" + scheme = "http://" + end + + if !proxy.empty? + "#{scheme}#{proxy}/videoplayback?#{raw_params}" + else + "#{scheme}#{env.request.headers["Host"]}/videoplayback?#{raw_params}" end end end @@ -248,7 +254,12 @@ module Invidious::Routes::API::Manifest manifest = response.body if local - manifest = manifest.gsub("https://www.youtube.com", env.request.headers["Host"]) + if CONFIG.https_only + scheme = "https://" + else + scheme = "http://" + end + manifest = manifest.gsub("https://www.youtube.com", "#{scheme}#{env.request.headers["Host"]}") manifest = manifest.gsub("index.m3u8", "index.m3u8?local=true") end