Update pixabay_api.py
Browse files- pixabay_api.py +7 -1
pixabay_api.py
CHANGED
|
@@ -9,6 +9,12 @@ def search_pixabay(query, num_results=5, min_width=1280, min_height=720, lang="e
|
|
| 9 |
if not query.strip():
|
| 10 |
raise ValueError("La consulta no puede estar vacía.")
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
url = "https://pixabay.com/api/videos/"
|
| 13 |
params = {
|
| 14 |
"key": api_key,
|
|
@@ -16,7 +22,7 @@ def search_pixabay(query, num_results=5, min_width=1280, min_height=720, lang="e
|
|
| 16 |
"lang": lang,
|
| 17 |
"min_width": min_width,
|
| 18 |
"min_height": min_height,
|
| 19 |
-
"per_page": num_results,
|
| 20 |
"video_type": "film"
|
| 21 |
}
|
| 22 |
response = requests.get(url, params=params)
|
|
|
|
| 9 |
if not query.strip():
|
| 10 |
raise ValueError("La consulta no puede estar vacía.")
|
| 11 |
|
| 12 |
+
# Asegurarse de que num_results esté dentro del rango permitido (3-200)
|
| 13 |
+
if num_results < 3:
|
| 14 |
+
num_results = 3
|
| 15 |
+
elif num_results > 200:
|
| 16 |
+
num_results = 200
|
| 17 |
+
|
| 18 |
url = "https://pixabay.com/api/videos/"
|
| 19 |
params = {
|
| 20 |
"key": api_key,
|
|
|
|
| 22 |
"lang": lang,
|
| 23 |
"min_width": min_width,
|
| 24 |
"min_height": min_height,
|
| 25 |
+
"per_page": num_results, # Asegurarse de que esté dentro del rango
|
| 26 |
"video_type": "film"
|
| 27 |
}
|
| 28 |
response = requests.get(url, params=params)
|