Trackers: affiche les jetons de seed (torr9 jeton_balance)
Champ tokens optionnel sur TrackerStat (None = tracker sans jetons) ; torr9 le remplit depuis jeton_balance de /users/me. Ligne « N jetons » conditionnelle sous envoyé/reçu, masquée pour les trackers sans système de jetons (c411).
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -215,7 +215,8 @@
|
||||
{% if t.ok %}<span class="ratio num">{{ t.ratio_h }}</span>
|
||||
{% else %}<span class="io"><span class="ko">{{ t.error }}</span></span>{% endif %}
|
||||
</div>
|
||||
{% if t.ok %}<div class="io num">envoyé {{ t.up_h }} · reçu {{ t.down_h }}</div>{% endif %}
|
||||
{% if t.ok %}<div class="io num">envoyé {{ t.up_h }} · reçu {{ t.down_h }}</div>
|
||||
{% if t.tokens is not none %}<div class="io num">{{ t.tokens_h }} {{ t.tokens_label }}</div>{% endif %}{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -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": [
|
||||
|
||||
Reference in New Issue
Block a user