fix: show only live torrent transfers
This commit is contained in:
@@ -462,9 +462,13 @@ def _qbit_torrent_direction(torrent: dict[str, Any]) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def _qbit_torrent_is_active(torrent: dict[str, Any]) -> bool:
|
||||
state = str(torrent.get("state") or "").lower()
|
||||
return bool(_qbit_torrent_direction(torrent)) or state in _QBITTORRENT_OTHER_ACTIVE_STATES
|
||||
def _qbit_torrent_transfer_direction(torrent: dict[str, Any]) -> str | None:
|
||||
"""Return a direction only while qBittorrent reports nonzero throughput."""
|
||||
if _safe_int(torrent.get("dlspeed")) > 0:
|
||||
return "downloading"
|
||||
if _safe_int(torrent.get("upspeed")) > 0:
|
||||
return "uploading"
|
||||
return None
|
||||
|
||||
|
||||
class QbittorrentWidgetSource:
|
||||
@@ -529,9 +533,9 @@ class QbittorrentWidgetSource:
|
||||
if widget_kind == "active":
|
||||
active = []
|
||||
for torrent in torrents.values():
|
||||
if not _qbit_torrent_is_active(torrent):
|
||||
direction = _qbit_torrent_transfer_direction(torrent)
|
||||
if not direction:
|
||||
continue
|
||||
direction = _qbit_torrent_direction(torrent)
|
||||
active.append(
|
||||
{
|
||||
"name": torrent.get("name"),
|
||||
|
||||
Reference in New Issue
Block a user