Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,8 @@ HOST = "http://mavpro.xyz:80"
|
|
| 7 |
USER = "uphMjgn0qw"
|
| 8 |
PASS = "iSwSA6zx7o"
|
| 9 |
USER_AGENT = "IPTVSmarters/1.0.3 (iPad; iOS 13.4.1; Scale/2.00)"
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
session = requests.Session()
|
| 13 |
session.headers.update({'User-Agent': USER_AGENT})
|
|
@@ -16,11 +17,9 @@ session.headers.update({'User-Agent': USER_AGENT})
|
|
| 16 |
def status():
|
| 17 |
return "SYSTEM_STABLE_150788"
|
| 18 |
|
| 19 |
-
|
|
|
|
| 20 |
def get_unified_list():
|
| 21 |
-
if request.args.get('token') != SECRET_TOKEN:
|
| 22 |
-
return "Unauthorized: Invalid Token", 401
|
| 23 |
-
|
| 24 |
categories = ["m3u_plus", "vod", "series"]
|
| 25 |
def generate():
|
| 26 |
yield "#EXTM3U\n"
|
|
@@ -31,26 +30,23 @@ def get_unified_list():
|
|
| 31 |
if r.status_code == 200:
|
| 32 |
for line in r.text.splitlines():
|
| 33 |
if line.startswith("#EXTM3U"): continue
|
| 34 |
-
|
|
|
|
| 35 |
except:
|
| 36 |
continue
|
| 37 |
return Response(stream_with_context(generate()), mimetype='text/plain')
|
| 38 |
|
| 39 |
-
|
|
|
|
| 40 |
def ghost_proxy(path):
|
| 41 |
-
if request.args.get('token') != SECRET_TOKEN:
|
| 42 |
-
return "Unauthorized: Missing Token", 401
|
| 43 |
-
|
| 44 |
target_url = f"{HOST}/{path}"
|
| 45 |
if request.query_string:
|
| 46 |
-
|
| 47 |
-
target_url = f"{HOST}/{path}?{clean_query}"
|
| 48 |
|
| 49 |
headers = {k: v for k, v in request.headers if k.lower() not in ['host', 'user-agent']}
|
| 50 |
|
| 51 |
try:
|
| 52 |
r = session.get(target_url, headers=headers, stream=True, timeout=15)
|
| 53 |
-
|
| 54 |
excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
|
| 55 |
resp_headers = [(name, value) for (name, value) in r.raw.headers.items()
|
| 56 |
if name.lower() not in excluded_headers]
|
|
|
|
| 7 |
USER = "uphMjgn0qw"
|
| 8 |
PASS = "iSwSA6zx7o"
|
| 9 |
USER_AGENT = "IPTVSmarters/1.0.3 (iPad; iOS 13.4.1; Scale/2.00)"
|
| 10 |
+
# This is your new secret path segment
|
| 11 |
+
SECRET_PATH = "mysecret123"
|
| 12 |
|
| 13 |
session = requests.Session()
|
| 14 |
session.headers.update({'User-Agent': USER_AGENT})
|
|
|
|
| 17 |
def status():
|
| 18 |
return "SYSTEM_STABLE_150788"
|
| 19 |
|
| 20 |
+
# Playlist link now uses a secure path
|
| 21 |
+
@app.route(f'/{SECRET_PATH}/11246.m3u')
|
| 22 |
def get_unified_list():
|
|
|
|
|
|
|
|
|
|
| 23 |
categories = ["m3u_plus", "vod", "series"]
|
| 24 |
def generate():
|
| 25 |
yield "#EXTM3U\n"
|
|
|
|
| 30 |
if r.status_code == 200:
|
| 31 |
for line in r.text.splitlines():
|
| 32 |
if line.startswith("#EXTM3U"): continue
|
| 33 |
+
# Replaces host with your Space and injects the secret path
|
| 34 |
+
yield line.replace(HOST, f"https://{request.host}/{SECRET_PATH}") + "\n"
|
| 35 |
except:
|
| 36 |
continue
|
| 37 |
return Response(stream_with_context(generate()), mimetype='text/plain')
|
| 38 |
|
| 39 |
+
# The proxy now only triggers if the secret path is the first part of the URL
|
| 40 |
+
@app.route(f'/{SECRET_PATH}/<path:path>')
|
| 41 |
def ghost_proxy(path):
|
|
|
|
|
|
|
|
|
|
| 42 |
target_url = f"{HOST}/{path}"
|
| 43 |
if request.query_string:
|
| 44 |
+
target_url += f"?{request.query_string.decode('utf-8')}"
|
|
|
|
| 45 |
|
| 46 |
headers = {k: v for k, v in request.headers if k.lower() not in ['host', 'user-agent']}
|
| 47 |
|
| 48 |
try:
|
| 49 |
r = session.get(target_url, headers=headers, stream=True, timeout=15)
|
|
|
|
| 50 |
excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
|
| 51 |
resp_headers = [(name, value) for (name, value) in r.raw.headers.items()
|
| 52 |
if name.lower() not in excluded_headers]
|