summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index a52eb311..073ed354 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -3230,6 +3230,33 @@ get "/videoplayback" do |env|
client = make_client(URI.parse(host))
response = client.head(url)
+ if response.status_code == 403
+ ip = query_params["ip"]
+ proxy = proxies.values.flatten.select { |proxy| proxy[:ip] == ip }
+ if proxy.empty?
+ halt env, status_code: 403
+ end
+
+ proxy = proxy[0]
+ # Try to find proxy in same region
+ proxy = proxies.select { |region, list| list.includes? proxy }.values[0].sample(1)[0]
+ if proxy.empty?
+ halt env, status_code: 403
+ end
+
+ client = HTTPClient.new(URI.parse(host))
+ client.read_timeout = 10.seconds
+ client.connect_timeout = 10.seconds
+
+ proxy = HTTPProxy.new(proxy_host: proxy[:ip], proxy_port: proxy[:port])
+ client.set_proxy(proxy)
+
+ response = client.head(url)
+
+ # For whatever reason the proxy needs to be set again
+ client.set_proxy(proxy)
+ end
+
if response.headers["Location"]?
url = URI.parse(response.headers["Location"])
env.response.headers["Access-Control-Allow-Origin"] = "*"
tle='2020-07-29 02:22:11 +0200'>2020-07-29issue with German title, English one is betterpixelcode 2020-07-29added German translationpixelcode 2020-07-16Closes #74 - Option to manually override theme.v1.1.37SimonBrazell 2020-07-15Take emojis back to Russian translationTotalCaesar659 2020-07-15Deploy extension to MS Edge.SimonBrazell 2020-07-15Take emojis back againTotalCaesar659 2020-07-14Grammar fixesTotalCaesar659 2020-07-14Add Russian translation for store descriptionsTotalCaesar659 2020-07-14Moved Privacy Policy to wiki pageSimonBrazell 2020-07-14Add version number and description to store.mdSimonBrazell 2020-07-14Added store listing translations to localesSimonBrazell 2020-07-13Fix autoplay param & French pop-up titlev1.1.36SimonBrazell