aboutsummaryrefslogtreecommitdiffstats
path: root/server.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-09-25 13:47:13 -0700
committerJames Taylor <user234683@users.noreply.github.com>2020-09-25 13:47:13 -0700
commitaa199cdf57671efc99bb77e54990764b8bb052c0 (patch)
tree4145270034874cd56621d889f350e643de00bbba /server.py
parentcf08f96de9d5470a72b97ee169641e25cfabc0e6 (diff)
downloadyt-local-aa199cdf57671efc99bb77e54990764b8bb052c0.tar.lz
yt-local-aa199cdf57671efc99bb77e54990764b8bb052c0.tar.xz
yt-local-aa199cdf57671efc99bb77e54990764b8bb052c0.zip
Use tor video routing instead of invidious for 403s
Using invidious isn't always successful, whereas Tor video routing appears to be near 100% successful.
Diffstat (limited to 'server.py')
-rw-r--r--server.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/server.py b/server.py
index 6fb61de..acce420 100644
--- a/server.py
+++ b/server.py
@@ -44,12 +44,12 @@ def proxy_site(env, start_response, video=False):
if env['QUERY_STRING']:
url += '?' + env['QUERY_STRING']
- if video and settings.route_tor == 1:
- response, cleanup_func = util.fetch_url_response(url, headers,
- use_tor=False,
- max_redirects=10)
- elif video:
+ if video:
+ params = urllib.parse.parse_qs(env['QUERY_STRING'])
+ params_use_tor = int(params.get('use_tor', '0')[0])
+ use_tor = (settings.route_tor == 2) or params_use_tor
response, cleanup_func = util.fetch_url_response(url, headers,
+ use_tor=use_tor,
max_redirects=10)
else:
response, cleanup_func = util.fetch_url_response(url, headers)