Update app.py
Browse files
app.py
CHANGED
@@ -497,6 +497,25 @@ async def multi_download(request: Request):
|
|
497 |
video_url = data.get('url')
|
498 |
quality = data.get('quality')
|
499 |
logger.info(f'{video_url}, {quality}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
if quality == "mp3":
|
501 |
parameter = 'type=audio'
|
502 |
else:
|
|
|
497 |
video_url = data.get('url')
|
498 |
quality = data.get('quality')
|
499 |
logger.info(f'{video_url}, {quality}')
|
500 |
+
if not video_url:
|
501 |
+
raise HTTPException(
|
502 |
+
status_code=400,
|
503 |
+
detail={"error": "Input 'url' is required."}
|
504 |
+
)
|
505 |
+
|
506 |
+
# Basic URL validation: checks if it starts with http/https and has some content after.
|
507 |
+
# For more robust validation, consider using a library like 'validators'.
|
508 |
+
if not re.match(r'^https?://\S+', str(video_url)): # Ensure video_url is treated as string for regex
|
509 |
+
raise HTTPException(
|
510 |
+
status_code=400,
|
511 |
+
detail={"error": f"Input 'url' ('{video_url}') is not a valid URL. It must start with http:// or https://."}
|
512 |
+
)
|
513 |
+
|
514 |
+
if not quality: # Checks for None or empty string
|
515 |
+
raise HTTPException(
|
516 |
+
status_code=400,
|
517 |
+
detail={"error": "This version of shortcut is outdated. Get the latest version of Chrunos Multi Downloader shortcut."}
|
518 |
+
)
|
519 |
if quality == "mp3":
|
520 |
parameter = 'type=audio'
|
521 |
else:
|