Add matrix background and prepare filters
This commit is contained in:
@@ -18,6 +18,8 @@ MAX_ATTEMPTS = 5
|
||||
BLOCK_TIME = timedelta(minutes=15)
|
||||
|
||||
MAX_SIZE_BYTES = 5*1024**3
|
||||
NB_PAGES = 2
|
||||
|
||||
YGG_PASSKEY = "xj1MgNuyzFKCjOtnawGBC2egDOciUg04"
|
||||
ALLDEBRID_KEY = "mtrQI4h583rHe2ZpvpbC"
|
||||
|
||||
@@ -87,18 +89,31 @@ def init_app(app):
|
||||
|
||||
# Préparer l'URL
|
||||
url = "https://yggapi.eu/torrents"
|
||||
|
||||
# Préparer les paramètres
|
||||
params = {
|
||||
"page": 1,
|
||||
"q": query,
|
||||
"category_id" : category_id,
|
||||
"order_by": "uploaded_at",
|
||||
"per_page": 100
|
||||
"page": 1,
|
||||
"q": query,
|
||||
"order_by": "uploaded_at",
|
||||
"per_page": 100
|
||||
}
|
||||
|
||||
# Ajouter la catégorie seulement si elle est renseignée et non vide
|
||||
if category_id:
|
||||
params["category_id"] = category_id
|
||||
|
||||
results = []
|
||||
|
||||
# Appeler l'API
|
||||
try:
|
||||
response = requests.get(url, params=params, timeout=5)
|
||||
response.raise_for_status() # déclenche une exception si erreur HTTP
|
||||
results = response.json()
|
||||
for page in range(1, NB_PAGES):
|
||||
params['page'] = page
|
||||
print("Appel API page", page, "avec params:", params)
|
||||
response = requests.get(url, params=params, timeout=5)
|
||||
response.raise_for_status()
|
||||
data = response.json() # ici c'est une liste directement
|
||||
print(f"Nombre de torrents reçus page {page}:", len(data))
|
||||
results.extend(data)
|
||||
except Exception as e:
|
||||
print("Erreur API Yggtorrent:", e)
|
||||
results = []
|
||||
|
||||
Reference in New Issue
Block a user