Spaces:
Paused
Paused
Update test.py
Browse files
test.py
CHANGED
|
@@ -20,11 +20,19 @@ def fetch_m3u8(url):
|
|
| 20 |
@app.get("/vixcloud/manifest.m3u8")
|
| 21 |
async def clone2_m3u8(d:str,token:str,expires:str,h:str = None, b:str = None, request: Request = None):
|
| 22 |
try:
|
| 23 |
-
m3u8 = f'{d}?token={token}&expires={expires}
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
print(f"Failed to fetch M3U8 file: {e}")
|
| 29 |
raise HTTPException(status_code=404, detail="M3U8 content not found")
|
| 30 |
'''
|
|
|
|
| 20 |
@app.get("/vixcloud/manifest.m3u8")
|
| 21 |
async def clone2_m3u8(d:str,token:str,expires:str,h:str = None, b:str = None, request: Request = None):
|
| 22 |
try:
|
| 23 |
+
m3u8 = f'{d}?token={token}&expires={expires}'
|
| 24 |
+
if h:
|
| 25 |
+
m3u8 = m3u8 + f'&h={h}'
|
| 26 |
+
if b:
|
| 27 |
+
m3u8 = m3u8 + f'&b={b}'
|
| 28 |
+
forwarded_proto = request.headers.get("x-forwarded-proto")
|
| 29 |
+
scheme = forwarded_proto if forwarded_proto else request.url.scheme
|
| 30 |
+
instance_url = f"{scheme}://{request.url.netloc}"
|
| 31 |
+
m3u8_content = await fetch_m3u8(m3u8)
|
| 32 |
+
modified_playlist = m3u8_content.replace("https://vixcloud.co/playlist/", f"{instance_url}/clony/")
|
| 33 |
+
|
| 34 |
+
return Response(content=modified_playlist, media_type='application/vnd.apple.mpegurl')
|
| 35 |
+
except Exception as e:
|
| 36 |
print(f"Failed to fetch M3U8 file: {e}")
|
| 37 |
raise HTTPException(status_code=404, detail="M3U8 content not found")
|
| 38 |
'''
|