From 51c5a05b94998f70bed1b19c0bd8ebed8e7bf6de Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 29 Oct 2024 19:02:05 -0300 Subject: [PATCH] Use POST requests for /videoplayback requests --- src/invidious/routes/video_playback.cr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index 5689b0c8..980ca976 100644 --- a/src/invidious/routes/video_playback.cr +++ b/src/invidious/routes/video_playback.cr @@ -3,6 +3,11 @@ module Invidious::Routes::VideoPlayback def self.get_video_playback(env) locale = env.get("preferences").as(Preferences).locale query_params = env.params.query + array = UInt8[0x78, 0] + protobuf = Bytes.new(array.size) + array.each_with_index do |byte, index| + protobuf[index] = byte + end fvip = query_params["fvip"]? || "3" mns = query_params["mn"]?.try &.split(",") @@ -100,7 +105,7 @@ module Invidious::Routes::VideoPlayback end begin - client.get(url, headers) do |resp| + client.post(url, headers, protobuf) do |resp| resp.headers.each do |key, value| if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase) env.response.headers[key] = value @@ -151,7 +156,7 @@ module Invidious::Routes::VideoPlayback headers["Range"] = "bytes=#{chunk_start}-#{chunk_end}" begin - client.get(url, headers) do |resp| + client.post(url, headers, protobuf) do |resp| if first_chunk if !env.request.headers["Range"]? && resp.status_code == 206 env.response.status_code = 200