diff --git a/backend/integrations/trackers.py b/backend/integrations/trackers.py index 85a5f4e..b816f1f 100644 --- a/backend/integrations/trackers.py +++ b/backend/integrations/trackers.py @@ -40,6 +40,12 @@ class TrackerStat: ratio: float = 0.0 up_bytes: int = 0 down_bytes: int = 0 + tokens: int | None = None # jetons/points de seed (None = le tracker n'en a pas) + tokens_label: str = "jetons" + + @property + def tokens_h(self) -> str: + return f"{self.tokens:,}".replace(",", " ") if self.tokens is not None else "" @staticmethod def _human(b: int) -> str: @@ -151,9 +157,11 @@ async def _fetch_torr9(spec: TrackerSpec) -> TrackerStat: up = int(u.get("total_uploaded_bytes", 0) or 0) + int(u.get("bonus_uploaded", 0) or 0) down = int(u.get("total_downloaded_bytes", 0) or 0) + int(u.get("bonus_downloaded", 0) or 0) + jetons = u.get("jeton_balance") return TrackerStat( spec.key, spec.label, ok=True, ratio=(up / down if down else 0.0), up_bytes=up, down_bytes=down, + tokens=int(jetons) if jetons is not None else None, ) diff --git a/backend/templates/dashboard.html b/backend/templates/dashboard.html index 9f78aa5..0c8550f 100644 --- a/backend/templates/dashboard.html +++ b/backend/templates/dashboard.html @@ -215,7 +215,8 @@ {% if t.ok %}{{ t.ratio_h }} {% else %}{{ t.error }}{% endif %} - {% if t.ok %}
envoyé {{ t.up_h }} · reçu {{ t.down_h }}
{% endif %} + {% if t.ok %}
envoyé {{ t.up_h }} · reçu {{ t.down_h }}
+ {% if t.tokens is not none %}
{{ t.tokens_h }} {{ t.tokens_label }}
{% endif %}{% endif %} {% endfor %} diff --git a/dev/preview.py b/dev/preview.py index 0806a26..2ff5bb8 100644 --- a/dev/preview.py +++ b/dev/preview.py @@ -67,8 +67,8 @@ CTX = { "vpn_ok": True, "vpn_port": 51820, }, "trackers": [ - {"ok": True, "label": "c411", "ratio_h": "1,04", "up_h": "378 Go", "down_h": "365 Go"}, - {"ok": True, "label": "torr9", "ratio_h": "0,82", "up_h": "1,21 To", "down_h": "1,47 To"}, + {"ok": True, "label": "c411", "ratio_h": "1,04", "up_h": "378 Go", "down_h": "365 Go", "tokens": None}, + {"ok": True, "label": "torr9", "ratio_h": "1,62", "up_h": "226 Go", "down_h": "140 Go", "tokens": 2168, "tokens_h": "2 168", "tokens_label": "jetons"}, {"ok": False, "label": "yggreborn", "error": "2FA requise"}, ], "ha_states": [