bep40 commited on
Commit
ba8a348
·
verified ·
1 Parent(s): 8f57b1f

Add /api/vtv/streams endpoint for fetching all VTV channel streams

Browse files
Files changed (1) hide show
  1. app_main.py +8 -2
app_main.py CHANGED
@@ -251,13 +251,19 @@ def api_match_detail_by_url(url: str = Query(...)):
251
  return JSONResponse(fetch_match_detail_by_url(url))
252
 
253
  # VTV Channels API
254
- from vtv_scraper import fetch_vtv_stream, XEMTV_CHANNELS, CDN_STREAMS
 
 
 
 
 
 
255
 
256
  @app.get('/api/vtv/stream/{channel_name}')
257
  def api_vtv_stream(channel_name: str):
258
  """Get stream URL for a specific VTV channel."""
259
  stream = fetch_vtv_stream(channel_name)
260
- return JSONResponse({'stream_url': stream, 'fallback': CDN_STREAMS.get(channel_name.upper(), '')})
261
 
262
  def _wc2026_bg_refresh():
263
  time.sleep(10)
 
251
  return JSONResponse(fetch_match_detail_by_url(url))
252
 
253
  # VTV Channels API
254
+ from vtv_scraper import fetch_vtv_stream, get_all_vtv_streams
255
+
256
+ @app.get('/api/vtv/streams')
257
+ def api_vtv_streams():
258
+ """Get all VTV channel streams."""
259
+ channels = get_all_vtv_streams()
260
+ return JSONResponse({'channels': channels})
261
 
262
  @app.get('/api/vtv/stream/{channel_name}')
263
  def api_vtv_stream(channel_name: str):
264
  """Get stream URL for a specific VTV channel."""
265
  stream = fetch_vtv_stream(channel_name)
266
+ return JSONResponse({'stream_url': stream, 'channel': channel_name})
267
 
268
  def _wc2026_bg_refresh():
269
  time.sleep(10)