Update app.py
Browse files
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 |
-
|
|
|
|
|
259 |
form_data = {"url": video_url}
|
260 |
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
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 |
|