Add advice and finish size filter

This commit is contained in:
2025-11-15 18:48:11 +01:00
parent 08be6a2455
commit a4fdd6e965
5 changed files with 56 additions and 29 deletions

View File

@@ -8,7 +8,6 @@ ALLDEBRID_API_KEY = os.getenv("ALLDEBRID_API_KEY")
NTFY_TOPIC_URL = os.getenv("NTFY_TOPIC_URL")
NTFY_TOKEN = os.getenv("NTFY_TOKEN")
MAX_SIZE_BYTES = 5*1024**3
NB_PAGES = 2
def check_alldebrid_status():
@@ -71,11 +70,11 @@ def search_torrents(query: str, category_id: str | None = None) -> list[dict]:
return results
def filter_and_format_torrents(torrents: list[dict]) -> list[dict]:
def filter_and_format_torrents(torrents: list[dict], max_size: int, season: int | None = None, episode: int | None = None) -> list[dict]:
"""Filtre les torrents trop gros et formate la taille et l'âge."""
filtered = []
for t in torrents:
if t['size'] <= MAX_SIZE_BYTES:
if t['size'] <= max_size*1024**3:
t['size'] = format_size(t['size'])
days, human = calculate_age(t['uploaded_at'])
t['age_days'] = days