mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-21 10:28:50 +00:00
API: make /api/v1/videos respect the 'local' parameter (#3567)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -101,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