recycleactor commited on
Commit
d8a60ae
·
verified ·
1 Parent(s): 1f722c5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -11
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
- async with httpx.AsyncClient(timeout=15, follow_redirects=True) as client:
 
 
 
 
 
 
 
489
  try:
490
- r = await client.get(url, headers=KINOSERIAL_HEADERS)
491
- return Response(
492
- content=r.text,
493
- status_code=r.status_code,
494
- media_type="text/html",
495
- headers={"Access-Control-Allow-Origin": "*"}
496
- )
 
 
497
  except Exception as e:
498
- print(f"[veoveo/embed] error fetching {url}: {e}")
499
- return Response(content=json.dumps({"error": str(e)}), status_code=500,
500
- media_type="application/json", headers={"Access-Control-Allow-Origin": "*"})
 
 
 
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")