From f01152eda1986c901886f81f98cfb5e9cb7bc48b Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Mon, 11 Mar 2019 13:14:30 -0500 Subject: [PATCH] Add 'host' to '/videoplayback' --- src/invidious.cr | 12 +++++++++--- src/invidious/videos.cr | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index c89c6771..ff17ab9b 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -4217,9 +4217,15 @@ end get "/videoplayback" do |env| query_params = env.params.query - fvip = query_params["fvip"]? || "3" - mn = query_params["mn"].split(",").pop - host = "https://r#{fvip}---#{mn}.googlevideo.com" + if query_params["host"]? && !query_params["host"].empty? + pp query_params["host"] + host = "https://#{query_params["host"]}" + else + fvip = query_params["fvip"]? || "3" + mn = query_params["mn"].split(",").pop + host = "https://r#{fvip}---#{mn}.googlevideo.com" + end + url = "/videoplayback?#{query_params.to_s}" headers = HTTP::Headers.new diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index b5bd2083..17d17d93 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -317,6 +317,7 @@ class Video end streams.each do |fmt| + fmt["url"] += "&host=" + (URI.parse(fmt["url"]).host || "") fmt["url"] += decrypt_signature(fmt, decrypt_function) end @@ -384,6 +385,7 @@ class Video end adaptive_fmts.each do |fmt| + fmt["url"] += "&host=" + (URI.parse(fmt["url"]).host || "") fmt["url"] += decrypt_signature(fmt, decrypt_function) end