diff --git a/files/routes/static.py b/files/routes/static.py index e91603ee1..99000a27a 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -434,16 +434,21 @@ def orgy(v): return redirect("/chat") if SITE == 'watchpeopledie.tv': + import ipinfo + access_token = environ.get("IPINFO_TOKEN").strip() + handler = ipinfo.getHandler(access_token) + @app.get("/1706708037797343.mp4") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) def geoblock(): ip = request.headers.get("X-Forwarded-For") - req = requests.get(f'http://ipinfo.io/{ip}/json') + try: - country = json.loads(req.text)['country'] + country = handler.getDetails(ip).country if country == 'AU': abort(403, "This video is blocked in Australia.") - except: - print(req.text, flush=True) + except Exception as e: + print(e, flush=True) + return send_file('/videos/1706708037797343.mp4')