Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
|
@@ -485,19 +485,31 @@ async def veoveo_embed(url: str):
|
|
| 485 |
if not url or "kinoserial" not in url:
|
| 486 |
return Response(content='{"error":"invalid url"}', status_code=400,
|
| 487 |
media_type="application/json", headers={"Access-Control-Allow-Origin": "*"})
|
| 488 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
try:
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
|
|
|
|
|
|
| 497 |
except Exception as e:
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
|
|
|
|
|
|
|
|
|
| 501 |
|
| 502 |
|
| 503 |
@app.get("/veoveo/search")
|
|
|
|
| 485 |
if not url or "kinoserial" not in url:
|
| 486 |
return Response(content='{"error":"invalid url"}', status_code=400,
|
| 487 |
media_type="application/json", headers={"Access-Control-Allow-Origin": "*"})
|
| 488 |
+
|
| 489 |
+
import traceback
|
| 490 |
+
|
| 491 |
+
# Try with different transport settings
|
| 492 |
+
for attempt, kwargs in enumerate([
|
| 493 |
+
{"timeout": 20, "follow_redirects": True},
|
| 494 |
+
{"timeout": 20, "follow_redirects": True, "verify": False},
|
| 495 |
+
]):
|
| 496 |
try:
|
| 497 |
+
async with httpx.AsyncClient(**kwargs) as client:
|
| 498 |
+
r = await client.get(url, headers=KINOSERIAL_HEADERS)
|
| 499 |
+
print(f"[veoveo/embed] attempt {attempt+1} OK: status={r.status_code} len={len(r.text)}")
|
| 500 |
+
return Response(
|
| 501 |
+
content=r.text,
|
| 502 |
+
status_code=r.status_code,
|
| 503 |
+
media_type="text/html",
|
| 504 |
+
headers={"Access-Control-Allow-Origin": "*"}
|
| 505 |
+
)
|
| 506 |
except Exception as e:
|
| 507 |
+
err_detail = traceback.format_exc()
|
| 508 |
+
print(f"[veoveo/embed] attempt {attempt+1} failed: {type(e).__name__}: {repr(e)}\n{err_detail}")
|
| 509 |
+
last_err = f"{type(e).__name__}: {repr(e)}"
|
| 510 |
+
|
| 511 |
+
return Response(content=json.dumps({"error": last_err}), status_code=500,
|
| 512 |
+
media_type="application/json", headers={"Access-Control-Allow-Origin": "*"})
|
| 513 |
|
| 514 |
|
| 515 |
@app.get("/veoveo/search")
|