Skip to content

feat(altmount): use native /api/nzb/streams API instead of SABnzbd+WebDAV#1023

Open
javi11 wants to merge 1 commit into
Viren070:mainfrom
javi11:feat/altmount-native-streams-api
Open

feat(altmount): use native /api/nzb/streams API instead of SABnzbd+WebDAV#1023
javi11 wants to merge 1 commit into
Viren070:mainfrom
javi11:feat/altmount-native-streams-api

Conversation

@javi11

@javi11 javi11 commented Jun 17, 2026

Copy link
Copy Markdown

Summary

This PR rewires AltmountService to use AltMount's native POST /api/nzb/streams endpoint instead of the SABnzbd history polling + WebDAV traversal path.

What changes

  • AltmountService._resolve() now calls POST {altmountUrl}/api/nzb/streams with an X-Api-Key header and a nzb_url body field
  • AltMount returns ready-to-play stream URLs directly — no SABnzbd job history poll, no WebDAV directory traversal, no separate WebDAV credentials required
  • webdavUser / webdavPassword are now optional in AltmountConfig (they fall back to empty strings so the base-class WebDAV client can still be constructed for the fallback path)
  • publicAltmountUrl replacement is applied to stream URLs the same way it was applied to WebDAV URLs
  • Existing UsenetStreamService.resolveCache is used so repeat requests for the same title still return instantly
  • selectFileInTorrentOrNZB is still used to pick the right file from multi-file releases (episode matching, etc.)

Backward compatibility

A transparent fallback to the existing SABnzbd + WebDAV path is triggered on HTTP 404 or 405 (endpoint not present on older AltMount versions) and on any network / parse error. No configuration changes are needed for existing AltMount deployments.

Why this is better

Old path New path
Credentials needed SABnzbd API key + WebDAV user/password API key only
Latency to first frame Full import + SABnzbd history poll + WebDAV stat Returns as soon as file is streamable (before post-processing)
Implementation addUrl → poll waitForHistorySlotcollectFiles (WebDAV) Single POST /api/nzb/streams
Dedup / caching Per-job SABnzbd dedup Server-side dedup + AIOStreams resolveCache

AltMount version requirement

The native endpoint is available from AltMount PR #693 onwards. Older versions fall back automatically.

Test plan

  • Configure AltMount backend with only altmountUrl, publicAltmountUrl, and altmountApiKey (no WebDAV creds) — verify a title resolves and plays in Stremio
  • Verify the _cached: true / _queue_status: "streamable" flow returns a URL before the full import completes
  • Configure AltMount backend with WebDAV creds pointing at an older AltMount instance (no native endpoint) — verify the SABnzbd+WebDAV fallback kicks in transparently
  • Verify multi-episode series: correct episode file is selected via selectFileInTorrentOrNZB
  • Verify publicAltmountUrl substitution when internal and public URLs differ

…bDAV

Replace the SABnzbd history polling + WebDAV directory traversal path in
AltmountService with a direct call to AltMount's native /api/nzb/streams
endpoint (available from AltMount v1.x+).

Changes:
- Override _resolve() to POST to /api/nzb/streams with X-Api-Key header
  and nzb_url body field, eliminating the history poll roundtrip
- AltMount now returns ready-to-play stream URLs directly, including an
  early "streamable" signal before post-processing completes
- Use selectFileInTorrentOrNZB for multi-file release selection, matching
  the existing base-class behaviour
- Replace internal altmountUrl with publicAltmountUrl in returned stream
  URLs when the two differ (same semantics as the WebDAV path)
- Cache the resolved URL via UsenetStreamService.resolveCache so repeat
  requests for the same title return instantly
- Fall back transparently to the SABnzbd+WebDAV path on HTTP 404/405 so
  older AltMount versions continue to work without any config changes
- Library items (serviceItemId without nzb) still delegate to the parent
  _resolveLibraryItem WebDAV path unchanged

Config changes:
- webdavUser and webdavPassword are now optional; they are only needed as
  a fallback for pre-native-API AltMount instances
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.

1 participant