Update app.py
Browse files
app.py
CHANGED
@@ -389,17 +389,19 @@ def extract_video_info(video_url: str) -> str:
|
|
389 |
else:
|
390 |
new_result = result
|
391 |
# Check if new_result has more than one item
|
392 |
-
if len(new_result) >
|
393 |
-
|
|
|
|
|
|
|
|
|
394 |
last_item = new_result[-1]
|
395 |
-
# Modify the format_id
|
396 |
last_item["format_id"] = f'{last_item["format_id"]} - Chrunos Shortcuts Premium Only'
|
397 |
-
# Modify the url
|
398 |
last_item["url"] = 'https://chrunos.com/premium-shortcuts/'
|
399 |
elif len(new_result) == 1:
|
400 |
new_item = {"url": "https://chrunos.com/premium-shortcuts/",
|
401 |
-
|
402 |
-
|
403 |
new_result.append(new_item)
|
404 |
|
405 |
return new_result
|
@@ -426,6 +428,16 @@ def extract_video_info(video_url: str) -> str:
|
|
426 |
|
427 |
@app.post("/test")
|
428 |
async def test_download(request: Request):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
data = await request.json()
|
430 |
video_url = data.get('url')
|
431 |
response = extract_video_info(video_url)
|
|
|
389 |
else:
|
390 |
new_result = result
|
391 |
# Check if new_result has more than one item
|
392 |
+
if len(new_result) > 3:
|
393 |
+
for i in range(3, len(new_result)):
|
394 |
+
item = new_result[i]
|
395 |
+
item["format_id"] = f'{item["format_id"]} - Chrunos Shortcuts Premium Only'
|
396 |
+
item["url"] = 'https://chrunos.com/premium-shortcuts/'
|
397 |
+
elif 2 <= len(new_result) <= 3:
|
398 |
last_item = new_result[-1]
|
|
|
399 |
last_item["format_id"] = f'{last_item["format_id"]} - Chrunos Shortcuts Premium Only'
|
|
|
400 |
last_item["url"] = 'https://chrunos.com/premium-shortcuts/'
|
401 |
elif len(new_result) == 1:
|
402 |
new_item = {"url": "https://chrunos.com/premium-shortcuts/",
|
403 |
+
"format_id": "Best Qaulity Video - Chrunos Shortcuts Premium Only"
|
404 |
+
}
|
405 |
new_result.append(new_item)
|
406 |
|
407 |
return new_result
|
|
|
428 |
|
429 |
@app.post("/test")
|
430 |
async def test_download(request: Request):
|
431 |
+
user_ip = get_user_ip(request)
|
432 |
+
if rate_limiter.is_rate_limited(user_ip):
|
433 |
+
current_count = rate_limiter.get_current_count(user_ip)
|
434 |
+
raise HTTPException(
|
435 |
+
status_code=429,
|
436 |
+
detail={
|
437 |
+
"error": "You have exceeded the maximum number of requests per day. Please try again tomorrow.",
|
438 |
+
"url": "https://t.me/chrunoss"
|
439 |
+
}
|
440 |
+
)
|
441 |
data = await request.json()
|
442 |
video_url = data.get('url')
|
443 |
response = extract_video_info(video_url)
|