Chrunos commited on
Commit
99b844b
·
verified ·
1 Parent(s): bab097b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -21
app.py CHANGED
@@ -255,30 +255,23 @@ async def get_track_download_url(video_url: str) -> str:
255
 
256
  async def process_url(video_url: str) -> str:
257
  try:
258
- api_url = "https://www.saveporn.net/convert/"
 
 
259
  form_data = {"url": video_url}
260
 
261
- async with httpx.AsyncClient() as client:
262
- response = await client.post(
263
- api_url,
264
- data=form_data,
265
- timeout=30.0 # 30 seconds timeout
266
- )
267
-
268
- response.raise_for_status()
269
-
270
- # Optional: Validate response format
271
- result = response.text
272
- if not result:
273
- raise ValueError("Empty response received")
274
-
275
- return result
276
-
277
- except httpx.TimeoutException:
278
- raise Exception("Request timed out")
279
- except httpx.HTTPStatusError as e:
280
- raise Exception(f"HTTP error occurred: {e.response.status_code}")
281
  except Exception as e:
 
282
  raise Exception(f"An unexpected error occurred: {str(e)}")
283
 
284
 
 
255
 
256
  async def process_url(video_url: str) -> str:
257
  try:
258
+ # Step 1: Download the URL
259
+ api_url = "https://www.example.net/convert/"
260
+ session = cloudscraper.create_scraper()
261
  form_data = {"url": video_url}
262
 
263
+ # Use the correct API endpoint
264
+ response = session.post(api_url, data=form_data)
265
+
266
+ # Check if the request was successful
267
+ response.raise_for_status()
268
+
269
+ return response.text
270
+ except requests.exceptions.RequestException as e:
271
+ # Handle network-related errors
272
+ raise Exception(f"Failed to process URL: {str(e)}")
 
 
 
 
 
 
 
 
 
 
273
  except Exception as e:
274
+ # Handle any other unexpected errors
275
  raise Exception(f"An unexpected error occurred: {str(e)}")
276
 
277