mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-21 18:38:50 +00:00
Merge branch 'master' into feature/login-redirect
This commit is contained in:
@@ -29,7 +29,7 @@ module Invidious::Routes::API::Manifest
|
||||
|
||||
if local
|
||||
uri = URI.parse(url)
|
||||
url = "#{uri.request_target}host/#{uri.host}/"
|
||||
url = "#{HOST_URL}#{uri.request_target}host/#{uri.host}/"
|
||||
end
|
||||
|
||||
"<BaseURL>#{url}</BaseURL>"
|
||||
@@ -42,7 +42,7 @@ module Invidious::Routes::API::Manifest
|
||||
|
||||
if local
|
||||
adaptive_fmts.each do |fmt|
|
||||
fmt["url"] = JSON::Any.new(URI.parse(fmt["url"].as_s).request_target)
|
||||
fmt["url"] = JSON::Any.new("#{HOST_URL}#{URI.parse(fmt["url"].as_s).request_target}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ module Invidious::Routes::API::V1::Videos
|
||||
|
||||
id = env.params.url["id"]
|
||||
region = env.params.query["region"]?
|
||||
proxy = {"1", "true"}.any? &.== env.params.query["local"]?
|
||||
|
||||
begin
|
||||
video = get_video(id, region: region)
|
||||
@@ -15,7 +16,9 @@ module Invidious::Routes::API::V1::Videos
|
||||
return error_json(500, ex)
|
||||
end
|
||||
|
||||
video.to_json(locale, nil)
|
||||
return JSON.build do |json|
|
||||
Invidious::JSONify::APIv1.video(video, json, locale: locale, proxy: proxy)
|
||||
end
|
||||
end
|
||||
|
||||
def self.captions(env)
|
||||
|
||||
@@ -35,6 +35,13 @@ module Invidious::Routes::VideoPlayback
|
||||
end
|
||||
end
|
||||
|
||||
# See: https://github.com/iv-org/invidious/issues/3302
|
||||
range_header = env.request.headers["Range"]?
|
||||
if range_header.nil?
|
||||
range_for_head = query_params["range"]? || "0-640"
|
||||
headers["Range"] = "bytes=#{range_for_head}"
|
||||
end
|
||||
|
||||
client = make_client(URI.parse(host), region)
|
||||
response = HTTP::Client::Response.new(500)
|
||||
error = ""
|
||||
@@ -70,6 +77,9 @@ module Invidious::Routes::VideoPlayback
|
||||
end
|
||||
end
|
||||
|
||||
# Remove the Range header added previously.
|
||||
headers.delete("Range") if range_header.nil?
|
||||
|
||||
if response.status_code >= 400
|
||||
env.response.content_type = "text/plain"
|
||||
haltf env, response.status_code
|
||||
@@ -91,14 +101,8 @@ module Invidious::Routes::VideoPlayback
|
||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||
|
||||
if location = resp.headers["Location"]?
|
||||
location = URI.parse(location)
|
||||
location = "#{location.request_target}&host=#{location.host}"
|
||||
|
||||
if region
|
||||
location += "®ion=#{region}"
|
||||
end
|
||||
|
||||
return env.redirect location
|
||||
url = Invidious::HttpServer::Utils.proxy_video_url(location, region: region)
|
||||
return env.redirect url
|
||||
end
|
||||
|
||||
IO.copy(resp.body_io, env.response)
|
||||
|
||||
Reference in New Issue
Block a user