mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-02-06 05:57:29 +00:00
initial support for base_url with invidious companion + proxy invidious_companion
This commit is contained in:
@@ -701,22 +701,28 @@ module YoutubeAPI
|
||||
# Send the POST request
|
||||
|
||||
begin
|
||||
response = COMPANION_POOL.client &.post(endpoint, headers: headers, body: data.to_json)
|
||||
body = response.body
|
||||
if (response.status_code != 200)
|
||||
raise Exception.new(
|
||||
"Error while communicating with Invidious companion: \
|
||||
status code: #{response.status_code} and body: #{body.dump}"
|
||||
)
|
||||
response_body = ""
|
||||
|
||||
COMPANION_POOL.client do |wrapper|
|
||||
companion_base_url = wrapper.companion.private_url.path
|
||||
puts "Using companion: #{wrapper.companion.private_url}"
|
||||
|
||||
response = wrapper.client.post(companion_base_url + endpoint, headers: headers, body: data.to_json)
|
||||
response_body = response.body
|
||||
|
||||
if response.status_code != 200
|
||||
raise Exception.new(
|
||||
"Error while communicating with Invidious companion: " \
|
||||
"status code: #{response.status_code} and body: #{response_body.dump}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# Convert result to Hash
|
||||
return JSON.parse(response_body).as_h
|
||||
rescue ex
|
||||
raise InfoException.new("Error while communicating with Invidious companion: " + (ex.message || "no extra info found"))
|
||||
end
|
||||
|
||||
# Convert result to Hash
|
||||
initial_data = JSON.parse(body).as_h
|
||||
|
||||
return initial_data
|
||||
end
|
||||
|
||||
####################################################################
|
||||
|
||||
Reference in New Issue
Block a user