feat(altmount): use native /api/nzb/streams API instead of SABnzbd+WebDAV#1023
Open
javi11 wants to merge 1 commit into
Open
feat(altmount): use native /api/nzb/streams API instead of SABnzbd+WebDAV#1023javi11 wants to merge 1 commit into
javi11 wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR rewires
AltmountServiceto use AltMount's nativePOST /api/nzb/streamsendpoint instead of the SABnzbd history polling + WebDAV traversal path.What changes
AltmountService._resolve()now callsPOST {altmountUrl}/api/nzb/streamswith anX-Api-Keyheader and anzb_urlbody fieldwebdavUser/webdavPasswordare now optional inAltmountConfig(they fall back to empty strings so the base-class WebDAV client can still be constructed for the fallback path)publicAltmountUrlreplacement is applied to stream URLs the same way it was applied to WebDAV URLsUsenetStreamService.resolveCacheis used so repeat requests for the same title still return instantlyselectFileInTorrentOrNZBis 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
addUrl→ pollwaitForHistorySlot→collectFiles(WebDAV)POST /api/nzb/streamsresolveCacheAltMount version requirement
The native endpoint is available from AltMount PR #693 onwards. Older versions fall back automatically.
Test plan
altmountUrl,publicAltmountUrl, andaltmountApiKey(no WebDAV creds) — verify a title resolves and plays in Stremio_cached: true/_queue_status: "streamable"flow returns a URL before the full import completesselectFileInTorrentOrNZBpublicAltmountUrlsubstitution when internal and public URLs differ