Skip to content

fix: SABnzbd queue.speed format for Homepage rate widget - #227

Open
scottcowan wants to merge 2 commits into
Nikorag:mainfrom
scottcowan:fix/sabnzbd-queue-speed-homepage
Open

fix: SABnzbd queue.speed format for Homepage rate widget#227
scottcowan wants to merge 2 commits into
Nikorag:mainfrom
scottcowan:fix/sabnzbd-queue-speed-homepage

Conversation

@scottcowan

Copy link
Copy Markdown
Contributor

Summary

Format queue.speed like real SABnzbd ("1.3 M", "0 ", …) instead of formatBytes(...) + "/s" ("1.2 MB/s"), so clients that parse the short form (notably Homepage’s SABnzbd widget) show a non-zero rate when downloading.

How we know this is correct

  1. SABnzbd contract — Official API docs show JSON such as "speed": "1.3 M" next to "kbpersec": "1296.02". That defines the intended string shape for queue.speed.
    https://sabnzbd.org/wiki/configuration/5.0/api

  2. Homepage parserfromUnits() splits queue.speed on a space and treats the second token as a single letter in B|K|M|G|T|P. Any other token (e.g. MB/s) makes indexOf fail and the rate becomes 0.
    https://github.com/gethomepage/homepage/blob/dev/src/widgets/sabnzbd/component.jsx

  3. Homepage tests (behaviour spec) — Their widget test passes speed: "1.0 M" and asserts the derived rate; that codifies the same contract as SABnzbd’s examples.
    https://github.com/gethomepage/homepage/blob/dev/src/widgets/sabnzbd/component.test.jsx

  4. Before / after — iPlayarr used formatBytes(totalSpeedKbs * 1024) + "/s" → strings like "500.00 KB/s", which do not match that parser. formatSabnzbdSpeedKbps() emits the short tier form so fromUnits matches SABnzbd + Homepage.

  5. Tests — Unit tests for formatSabnzbdSpeedKbps (including 1296.02"1.3 M") and updated QueueEndpoint expectations; full npm test (373 tests) passes.

Related

Homepage parses speed as '<number> <K|M|G>' (e.g. '1.3 M'). formatBytes()+'/s'
produced '1.2 MB/s', so fromUnits() returned 0 and rate always showed zero.

Use formatSabnzbdSpeedKbps() aligned with SABnzbd API examples.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread tests/utils/formatters.test.ts
…parser

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@scottcowan

Copy link
Copy Markdown
Contributor Author

The trailing space is intentional — it matches real SABnzbd's API output ("speed": "0 " when idle). The SABnzbd queue response shows this format ("speed": "1.3 M"), and Homepage's fromUnits() splits on the space to extract the unit letter, so trimming to "0" would mean no space is found, the split returns a single token, and the rate breaks.

I've added a test (fd62096) that documents this contract explicitly: '0 '.split(' ') gives ['0', '']unit is an empty string, not undefined, which is what proves the space was found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants