bep40 commited on
Commit
e80f9c8
·
1 Parent(s): aee7763

Fix match detail: add endpoint + parallel scrape (#9)

Browse files

- Upload main.py (2d2cc2e92d42ade3d866993d789e6e38313a1de9)

Files changed (1) hide show
  1. main.py +16 -0
main.py CHANGED
@@ -294,6 +294,22 @@ def api_livescore_date(date:str):return JSONResponse({"html":fetch_bongda_api(f"
294
  def api_match_commentaries(event_id:int):return JSONResponse({"html":fetch_bongda_api(f"/api/fixtures/commentaries?event_id={event_id}")})
295
  @app.get("/api/match/{event_id}/stats")
296
  def api_match_stats(event_id:int):return JSONResponse({"html":fetch_bongda_api(f"/api/event-standing/player-performance?event_id={event_id}")})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  @app.get("/api/livescore/featured")
298
  def api_livescore_featured():
299
  def _f():
 
294
  def api_match_commentaries(event_id:int):return JSONResponse({"html":fetch_bongda_api(f"/api/fixtures/commentaries?event_id={event_id}")})
295
  @app.get("/api/match/{event_id}/stats")
296
  def api_match_stats(event_id:int):return JSONResponse({"html":fetch_bongda_api(f"/api/event-standing/player-performance?event_id={event_id}")})
297
+
298
+ # ===== MATCH DETAIL (server-side scrape from bongda.com.vn) =====
299
+ from match_detail_v2 import fetch_match_detail, fetch_match_detail_by_url
300
+
301
+ @app.get("/api/match/{event_id}/detail")
302
+ def api_match_detail(event_id: int, url: str = Query(default="")):
303
+ """Get full match detail by scraping bongda.com.vn server-side."""
304
+ try:
305
+ if url:
306
+ data = fetch_match_detail_by_url(url)
307
+ else:
308
+ data = fetch_match_detail(event_id)
309
+ return JSONResponse(data)
310
+ except Exception as e:
311
+ return JSONResponse({"event_id": event_id, "found": False, "error": str(e)})
312
+
313
  @app.get("/api/livescore/featured")
314
  def api_livescore_featured():
315
  def _f():