From a4fdd6e965ddabe359b46f7754ee496c0557fbb7 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 15 Nov 2025 18:48:11 +0100 Subject: [PATCH] Add advice and finish size filter --- backend/api.py | 5 ++-- backend/routes.py | 6 +++- frontend/static/css/style.css | 5 ++-- frontend/templates/base.html | 23 ++++++++-------- frontend/templates/dashboard.html | 46 ++++++++++++++++++++++++------- 5 files changed, 56 insertions(+), 29 deletions(-) diff --git a/backend/api.py b/backend/api.py index 1a88d48..10c834f 100644 --- a/backend/api.py +++ b/backend/api.py @@ -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 diff --git a/backend/routes.py b/backend/routes.py index ec2351f..6221718 100644 --- a/backend/routes.py +++ b/backend/routes.py @@ -55,12 +55,16 @@ def init_app(app): def search(): query = request.args.get('query') category_id = request.args.get('category_id') + max_size = request.args.get('max_size', default=5, type=int) + + season = request.args.get('season', type=int) # None si absent + episode = request.args.get('episode', type=int) # None si absent # 1. Recherche brute torrents = search_torrents(query, category_id) # 2. Filtrage et formatage - filtered_results = filter_and_format_torrents(torrents) + filtered_results = filter_and_format_torrents(torrents, max_size, season, episode) return render_template( 'search_results.html', diff --git a/frontend/static/css/style.css b/frontend/static/css/style.css index dcfcc47..302b720 100644 --- a/frontend/static/css/style.css +++ b/frontend/static/css/style.css @@ -11,7 +11,6 @@ body { header { color: #00ff41; text-shadow: 0 0 10px #00ff41; - margin-bottom: 20px; text-align: center; } @@ -29,7 +28,7 @@ td { .user-info { display:inline; - margin-right:10px; + margin: 5px; color:white; font-weight:bold; } @@ -40,7 +39,7 @@ td { .second-header { font-weight: bold; - margin-bottom: 20px; + margin: 10px; } #results-table td:nth-child(2), diff --git a/frontend/templates/base.html b/frontend/templates/base.html index 8b33e11..a199ab3 100644 --- a/frontend/templates/base.html +++ b/frontend/templates/base.html @@ -30,21 +30,20 @@
+ {% if session.alldebrid_active is defined %} + {% if session.alldebrid_active %} +
+ ✅ Service fonctionnel +
+ {% else %} +
+ ⚠️ Service en panne, je répare ! +
+ {% endif %} + {% endif %} {% endif %} - {% if session.alldebrid_active is defined %} - {% if session.alldebrid_active %} -
- ✅ Service fonctionnel -
- {% else %} -
- ⚠️ Service en panne, je répare ! -
- {% endif %} - {% endif %} -
{% block content %}{% endblock %}
diff --git a/frontend/templates/dashboard.html b/frontend/templates/dashboard.html index 1c3e88a..f628252 100644 --- a/frontend/templates/dashboard.html +++ b/frontend/templates/dashboard.html @@ -1,6 +1,6 @@ {% extends 'base.html' %} -{% block title %}Tableau de bord{% endblock %} +{% block title %}Les films de Lulu{% endblock %} {% block matrix %} @@ -12,21 +12,31 @@
+
+ + +
- + + - - - + @@ -91,12 +101,12 @@
- +
-
+