Spaces:
Paused
Paused
Update test.py
Browse files
test.py
CHANGED
|
@@ -27,7 +27,7 @@ async def clone2_m3u8(d:str,token:str,expires:str,h:str):
|
|
| 27 |
except requests.RequestException as e:
|
| 28 |
print(f"Failed to fetch M3U8 file: {e}")
|
| 29 |
raise HTTPException(status_code=404, detail="M3U8 content not found")
|
| 30 |
-
|
| 31 |
@app.get("/clone/manifest.m3u8")
|
| 32 |
async def clone_m3u8(d: str = None):
|
| 33 |
if d:
|
|
@@ -40,6 +40,50 @@ async def clone_m3u8(d: str = None):
|
|
| 40 |
print(f"Failed to fetch M3U8 file: {e}")
|
| 41 |
raise HTTPException(status_code=404, detail="M3U8 content not found")
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
async def get_version():
|
| 45 |
#Extract the version from the main page of the site
|
|
|
|
| 27 |
except requests.RequestException as e:
|
| 28 |
print(f"Failed to fetch M3U8 file: {e}")
|
| 29 |
raise HTTPException(status_code=404, detail="M3U8 content not found")
|
| 30 |
+
'''
|
| 31 |
@app.get("/clone/manifest.m3u8")
|
| 32 |
async def clone_m3u8(d: str = None):
|
| 33 |
if d:
|
|
|
|
| 40 |
print(f"Failed to fetch M3U8 file: {e}")
|
| 41 |
raise HTTPException(status_code=404, detail="M3U8 content not found")
|
| 42 |
|
| 43 |
+
'''
|
| 44 |
+
|
| 45 |
+
@app.get("/vixcloud/manifest.m3u8", methods=["GET", "HEAD"])
|
| 46 |
+
async def clone2_m3u8(d:str,token:str,expires:str,h:str = None, b:str = None, request: Request = None):
|
| 47 |
+
try:
|
| 48 |
+
m3u8 = f'{d}?token={token}&expires={expires}'
|
| 49 |
+
if h:
|
| 50 |
+
m3u8 = m3u8 + f'&h={h}'
|
| 51 |
+
if b:
|
| 52 |
+
m3u8 = m3u8 + f'&b={b}'
|
| 53 |
+
forwarded_proto = request.headers.get("x-forwarded-proto")
|
| 54 |
+
scheme = forwarded_proto if forwarded_proto else request.url.scheme
|
| 55 |
+
instance_url = f"{scheme}://{request.url.netloc}"
|
| 56 |
+
m3u8_content = fetch_m3u8(m3u8)
|
| 57 |
+
modified_playlist = m3u8_content.replace("https://vixcloud.co/playlist/", f"{instance_url}/clony/")
|
| 58 |
+
|
| 59 |
+
return Response(content=modified_playlist, media_type='application/vnd.apple.mpegurl')
|
| 60 |
+
except Exception as e:
|
| 61 |
+
print(f"Failed to fetch M3U8 file: {e}")
|
| 62 |
+
raise HTTPException(status_code=404, detail="M3U8 content not found")
|
| 63 |
+
|
| 64 |
+
@app.get("/clony/{segment:path}", methods=["GET", "HEAD"])
|
| 65 |
+
async def clony_m3u8(segment: str, request: Request):
|
| 66 |
+
base_url = "https://vixcloud.co/playlist/"
|
| 67 |
+
full_url = f"{base_url}{segment}?{request.query_params}"
|
| 68 |
+
m3u8_content = await fetch_m3u8(full_url)
|
| 69 |
+
return Response(content=m3u8_content, media_type='application/vnd.apple.mpegurl')
|
| 70 |
+
|
| 71 |
+
@app.get('/storage/enc.key')
|
| 72 |
+
async def get_key():
|
| 73 |
+
response = requests.get('https://vixcloud.co/storage/enc.key', headers = {"User-Agent": User_Agent, "user-agent": User_Agent})
|
| 74 |
+
|
| 75 |
+
response_headers = {
|
| 76 |
+
'date': response.headers['date'],
|
| 77 |
+
'content-length': response.headers['content-length'],
|
| 78 |
+
'content-type': 'application/octet-stream',
|
| 79 |
+
'access-control-allow-origin': '*'
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
return Response(
|
| 83 |
+
response.content,
|
| 84 |
+
response.status_code,
|
| 85 |
+
response_headers
|
| 86 |
+
)
|
| 87 |
|
| 88 |
async def get_version():
|
| 89 |
#Extract the version from the main page of the site
|