Skip to content

Commit

Permalink
fix(limiter): calculated the limit percentage wrong (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
buroa authored Oct 28, 2024
1 parent a1090ec commit ebf857a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions qbtools/commands/limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def process():
qbittorrent_queue, qbittorrent_current_limit = qbittorrent_data(app)
sabnzbd_queue, sabnzbd_current_limit = sabnzbd_data(app)

qbittorrent_current_limit = int(qbittorrent_current_limit / 1024 / 1024)
sabnzbd_current_limit = int(sabnzbd_current_limit / 1024 / 1024)

logger.debug(
f"qBittorrent: {qbittorrent_queue} item(s) @ {qbittorrent_current_limit} MB/s"
)
Expand Down Expand Up @@ -45,7 +48,7 @@ def process():
apikey=app.sabnzbd_apikey,
mode="config",
name="speedlimit",
value=limit,
value=int(percentage * 100),
),
)
logger.info(
Expand Down Expand Up @@ -75,7 +78,7 @@ def parse_sabnzbd_host(app) -> str:

def qbittorrent_data(app) -> Tuple[int, int]:
torrents = len(app.client.torrents.info(status_filter="downloading"))
download_limit = app.client.transfer_download_limit() / 1024 / 1024
download_limit = app.client.transfer_download_limit()
return torrents, download_limit


Expand All @@ -85,7 +88,7 @@ def sabnzbd_data(app) -> Tuple[int, int]:
)
return (
int(data.get("queue", {}).get("noofslots", 0)) if data else 0,
int(data.get("queue", {}).get("speedlimit", 0)) if data else 0,
int(data.get("queue", {}).get("speedlimit_abs", 0)) if data else 0,
)


Expand Down

0 comments on commit ebf857a

Please sign in to comment.