Compare commits
4 Commits
40bda207e1
...
d5ead66a07
Author | SHA1 | Date | |
---|---|---|---|
d5ead66a07 | |||
f8436927cf | |||
3b4ee632b1 | |||
6b868c2b63 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
.vscode
|
||||
__pycache__
|
||||
test.mp4
|
||||
secrets.env
|
||||
env
|
@ -13,8 +13,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
:80 {
|
||||
#nl.u2b.cx u2b.cx {
|
||||
{$CADDY_SITE:":80"} {
|
||||
log
|
||||
tls {
|
||||
dns porkbun {
|
||||
api_key {env.PORKBUN_API_KEY}
|
||||
|
@ -22,7 +22,7 @@ services:
|
||||
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
|
||||
- caddy_data:/data
|
||||
- caddy_config:/config
|
||||
env_file: secrets.env
|
||||
env_file: env
|
||||
volumes:
|
||||
caddy_data:
|
||||
caddy_config:
|
30
server.py
30
server.py
@ -26,10 +26,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
def address_string(self):
|
||||
return getattr(self, 'headers', {}).get('X-Forwarded-For', '').split(',')[0] or self.client_address[0]
|
||||
|
||||
def is_pc_vrchat(self):
|
||||
ua = self.headers.get('User-Agent', '')
|
||||
ae = self.headers.get('Accept-Encoding', '')
|
||||
return ua.startswith("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/") and ua.endswith(" Safari/537.36") and ae == "identity"
|
||||
#def is_pc_vrchat(self):
|
||||
# ua = self.headers.get('User-Agent', '')
|
||||
# ae = self.headers.get('Accept-Encoding', '')
|
||||
# return ua.startswith("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/") and ua.endswith(" Safari/537.36") and ae == "identity"
|
||||
|
||||
def send_error(self, code, message=""):
|
||||
body = bytes(message, "utf-8")
|
||||
@ -48,11 +48,11 @@ class Handler(BaseHTTPRequestHandler):
|
||||
path = unquote(self.path)
|
||||
match = re.match("\/(?:id\/|(?:https?:\/\/)?(?:(?:www\.|music\.|m\.)?youtube\.com\/(?:watch\?v=|shorts\/)|youtu\.be\/))([A-Za-z0-9_-]{11})", path)
|
||||
if match:
|
||||
if self.is_pc_vrchat():
|
||||
self.send_response(302)
|
||||
self.send_header("Location", "https://www.youtube.com/watch?v=" + match[1])
|
||||
self.end_headers()
|
||||
return
|
||||
#if self.is_pc_vrchat():
|
||||
# self.send_response(302)
|
||||
# self.send_header("Location", "https://www.youtube.com/watch?v=" + match[1])
|
||||
# self.end_headers()
|
||||
# return
|
||||
query = match[1]
|
||||
else:
|
||||
query = "ytsearch:" + path[1:]
|
||||
@ -103,12 +103,12 @@ class Handler(BaseHTTPRequestHandler):
|
||||
elif 'url' not in ctx:
|
||||
ctx['event'].wait(60)
|
||||
|
||||
if self.is_pc_vrchat():
|
||||
if ctx.get('id'):
|
||||
self.send_response(302)
|
||||
self.send_header("Location", "https://www.youtube.com/watch?v=" + ctx['id'])
|
||||
self.end_headers()
|
||||
return
|
||||
#if self.is_pc_vrchat():
|
||||
# if ctx.get('id'):
|
||||
# self.send_response(302)
|
||||
# self.send_header("Location", "https://www.youtube.com/watch?v=" + ctx['id'])
|
||||
# self.end_headers()
|
||||
# return
|
||||
|
||||
if not ctx.get('url'):
|
||||
if 'exception' in ctx:
|
||||
|
Loading…
Reference in New Issue
Block a user