tecuts commited on
Commit
1cfa229
·
verified ·
1 Parent(s): 0664829

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -134,12 +134,16 @@ async def process_video(request: Request, background_tasks: BackgroundTasks):
134
  # --- Step 1: Call the Info API ---
135
  info_api_url = f"{BASE_URL}/api/info"
136
  params = {"url": video_url}
 
137
  try:
138
- async with httpx.AsyncClient() as client:
 
139
  logging.info(f"Calling Info API: {info_api_url}")
140
  response = await client.get(info_api_url, params=params, timeout=30.0)
141
  response.raise_for_status()
142
  video_data = response.json()
 
 
143
  video_stream_url, audio_stream_url = get_best_formats_with_fallback(video_data, quality)
144
  except httpx.RequestError as e:
145
  logging.error(f"Info API connection failed: {e}")
 
134
  # --- Step 1: Call the Info API ---
135
  info_api_url = f"{BASE_URL}/api/info"
136
  params = {"url": video_url}
137
+ # ... inside the process_video function
138
  try:
139
+ # The fix is to add `follow_redirects=True` here
140
+ async with httpx.AsyncClient(follow_redirects=True) as client:
141
  logging.info(f"Calling Info API: {info_api_url}")
142
  response = await client.get(info_api_url, params=params, timeout=30.0)
143
  response.raise_for_status()
144
  video_data = response.json()
145
+ response.raise_for_status()
146
+ video_data = response.json()
147
  video_stream_url, audio_stream_url = get_best_formats_with_fallback(video_data, quality)
148
  except httpx.RequestError as e:
149
  logging.error(f"Info API connection failed: {e}")