Skip to content

feat(stremio): instant mount, X-Api-Key auth, NZB by URL, cached flag#693

Open
javi11 wants to merge 1 commit into
mainfrom
feat/stremio-instant-mount-aiostreams-backend
Open

feat(stremio): instant mount, X-Api-Key auth, NZB by URL, cached flag#693
javi11 wants to merge 1 commit into
mainfrom
feat/stremio-instant-mount-aiostreams-backend

Conversation

@javi11

@javi11 javi11 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

Makes AltMount a first-class backend for AIOStreams (and any Stremio integration) by closing the latency gap between NZB submission and first playable frame.

Changes

Instant mount (A1 — internal/importer/service.go, internal/progress/progress_broadcaster.go)

  • ProgressBroadcaster now has a NotifyStreamable(queueID, storagePath) method that broadcasts a "streamable" event the moment StoragePath is written to the DB — before post-processing (symlinks, STRM files, health scheduling) and before status=Completed.
  • handleProcessingSuccess in the importer service calls this immediately after AddStoragePath.

Early stream return (A1 — nzb_stremio_handlers.go, stremio_addon_handlers.go)

  • waitAndRespond (native /api/nzb/streams) and waitAndRedirectToStream (addon play path) both listen for "streamable" events and return/redirect immediately — no longer blocked on status=Completed.
  • Upfront check also catches items already in processing state with a storage path set (covers the subscribe-after-event race).

X-Api-Key header auth (A5 — nzb_stremio_handlers.go)

  • POST /api/nzb/streams now accepts the raw API key via X-Api-Key header in addition to the download_key form field (SHA256 hash). AIOStreams sends altmountApiKey in X-Api-Key — this makes it work without any extra config on the AIOStreams side.

NZB by URL (A5 — nzb_stremio_handlers.go)

  • New nzb_url form field: callers pass an NZB download URL instead of uploading file bytes, removing an extra HTTP round-trip.

_cached flag (A5 — nzb_stremio_handlers.go)

  • StremioStreamsResponse gains _cached: bool. Set to true when streams are served from an already-completed queue item. AIOStreams can use this to show a lightning/instant badge without probing WebDAV.

Test plan

  • Single MKV NZB: submit via POST /api/nzb/streams with X-Api-Key header → confirm response arrives before status=Completed (streamable stage) and _cached=false
  • Same NZB a second time → _cached=true, response is instant
  • nzb_url field: pass an NZB download URL instead of file upload → same result
  • RAR archive NZB: confirm streams returned as soon as RAR headers are parsed and metadata written
  • Failed/dead release: confirm clean HTTP error response, no hang
  • Addon play path (GET /stremio/:key/play): confirm 302 redirect fires at streamable stage, not at completed
  • Existing Plex/WebDAV behaviour unchanged (post-processing still runs to completion async)
  • go test ./internal/api/... ./internal/importer/... ./internal/progress/... passes

- Broadcast "streamable" event from ProgressBroadcaster as soon as storage
  path is written (before post-processing), allowing Stremio waiters to
  return playable stream URLs without waiting for status=Completed

- Accept X-Api-Key header (raw API key) on POST /api/nzb/streams so
  AIOStreams can authenticate without computing the SHA256 download_key

- Accept nzb_url form field to let callers pass an NZB download URL
  instead of uploading file bytes — removes an extra round-trip for
  AIOStreams and other integrations

- Add _cached bool field to StremioStreamsResponse so AIOStreams can show
  an instant/lightning tag when the NZB was already processed

- waitAndRespond and waitAndRedirectToStream now handle "streamable" events
  and also perform an upfront check for items already in processing state
  with a storage path set (covers the subscribe-after-event race)
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