add youtube consent logic

This commit is contained in:
Roy Olav Purser 2021-05-09 20:34:30 +02:00
parent 82029e2537
commit b2550a8c1c
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -126,9 +126,12 @@ class MainHandler(tornado.web.RequestHandler):
proxy = proxies.get(provider) proxy = proxies.get(provider)
src = providers[provider] + self.request.path src = providers[provider] + self.request.path
try: try:
resp = requests.head(src) resp = requests.head(src, allow_redirects=True)
if resp is not None: if resp is not None:
src = resp.url src = resp.url
if isinstance(src, str) and "consent.youtube.com" in src:
video_id = self.request.path.strip("/")
src = f'https://www.youtube.com/watch?v={video_id}'
except Exception as e: except Exception as e:
print(e) print(e)
else: else: