### Advanced Setup with Health Checks and Regional Search Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Comprehensive example for advanced configuration, including health checks, regional search, TMDB, and Easynews integration. ```bash ADDON_BASE_URL=https://my-addon.example.com ADDON_SHARED_SECRET=super-secret-admin-token ADDON_NAME="Regional Streamer" INDEXER_MANAGER=nzbhydra INDEXER_MANAGER_URL=http://nzbhydra:5076 INDEXER_MANAGER_API_KEY=nzbhydra-api-key NZBDAV_URL=http://nzbdav:3000 NZBDAV_API_KEY=nzbdav-api-key NZB_SORT_ORDER=language,quality,size NZB_PREFERRED_LANGUAGE=Tamil,Malayalam,Hindi NZB_STREAM_PROTECTION=health-check-auto-advance NZB_TRIAGE_ENABLED=true NZB_TRIAGE_NNTP_HOST=news.provider.net NZB_TRIAGE_NNTP_PORT=563 NZB_TRIAGE_NNTP_USER=usenet-user NZB_TRIAGE_NNTP_PASS=usenet-password TMDB_ENABLED=true TMDB_API_KEY=tmdb-api-key TMDB_SEARCH_MODE=english_and_regional TMDB_SEARCH_LANGUAGES=ta-IN,ml-IN,hi-IN EASYNEWS_ENABLED=true EASYNEWS_USERNAME=easynews-user EASYNEWS_PASSWORD=easynews-pass ``` -------------------------------- ### Minimal Docker Configuration Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Example environment variables for a basic Docker setup, including addon, indexer manager, and NZBDAV settings. ```bash ADDON_BASE_URL=https://my-addon.example.com ADDON_SHARED_SECRET=super-secret-admin-token INDEXER_MANAGER=prowlarr INDEXER_MANAGER_URL=http://prowlarr:9696 INDEXER_MANAGER_API_KEY=prowlarr-api-key INDEXER_MANAGER_INDEXERS=-1 NZBDAV_URL=http://nzbdav:3000 NZBDAV_API_KEY=nzbdav-api-key NZBDAV_WEBDAV_USER=webdav-user NZBDAV_WEBDAV_PASS=webdav-pass PORT=7000 CONFIG_DIR=/data/config ``` -------------------------------- ### Minimal Setup Environment Variables Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/README.md Set these environment variables for a basic Usenetstreamer setup. Ensure you replace placeholder values with your actual credentials and URLs. ```bash ADDON_BASE_URL=https://my-addon.example.com ADDON_SHARED_SECRET=super-secret-token INDEXER_MANAGER=prowlarr INDEXER_MANAGER_URL=http://prowlarr:9696 INDEXER_MANAGER_API_KEY=your-api-key NZBDAV_URL=http://nzbdav:3000 NZBDAV_API_KEY=your-api-key NZBDAV_WEBDAV_USER=user NZBDAV_WEBDAV_PASS=pass PORT=7000 ``` -------------------------------- ### Detailed Parse Release Metadata Example Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/RELEASE-PARSER.md Provides a comprehensive example of parsing a release title with size and file count, then logging specific metadata fields. ```javascript const meta = parseReleaseMetadata( 'Breaking.Bad.S05E16.1080p.AMZN.WEB-DL.DDP5.1.H.264-Mooi1990', 3000000000, 42 ) console.log(meta.resolution) // "1080p" console.log(meta.quality) // "WebRip" console.log(meta.languages) // ["English"] console.log(meta.codec) // "h264" console.log(meta.audio) // ["DDP5.1"] console.log(meta.group) // "Mooi1990" ``` -------------------------------- ### Start Docker Container Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/windows-native-setup.md Command to start a stopped UsenetStreamer Docker container. ```powershell docker start usenetstreamer ``` -------------------------------- ### Usage Example: Finding Releases with Indexer Service Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/INDEXER-SERVICE.md Shows a complete usage example of the indexer service, including configuration, executing searches for specific movie IDs, and logging results. ```javascript const indexerService = require('./src/services/indexer') // Ensure indexer is configured before use try { indexerService.ensureIndexerManagerConfigured() } catch (error) { console.error('Indexer not configured:', error.message) process.exit(1) } // Execute searches async function findReleases(imdbId) { const plans = [ { type: 'movie', query: imdbId }, { type: 'movie', query: 'The Shawshank Redemption' } ] const results = await indexerService.queryIndexers(plans, { timeout: 60000, deduplicate: true }) console.log(`Found ${results.length} releases`) results.forEach(result => { console.log(`${result.title} (${result.size} bytes)`) }) } findReleases('tt0111161').catch(console.error) ``` -------------------------------- ### Primary Endpoint Examples Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/README.md Examples of how to call the primary streaming endpoint for movies and series. The type and ID parameters specify the content to stream. ```bash GET /stream/movie/tt0111161.json GET /:token/stream/series/tvdb:121361:2:5.json ``` -------------------------------- ### Install Docker and Compose on Ubuntu Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/beginners-guide.md Installs Docker CE, CLI, containerd, buildx plugin, and compose plugin on Ubuntu 22.04. Adds the current user to the docker group. ```bash sudo apt update sudo apt install -y ca-certificates curl gnupg lsb-release sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo usermod -aG docker $USER newgrp docker ``` -------------------------------- ### Build NNTP configuration Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/TRIAGE-SERVICE.md Constructs NNTP connection config from environment or overrides. This example shows how to get the configuration and log connection details. ```javascript const config = buildTriageNntpConfig() ``` ```javascript const config = buildTriageNntpConfig() console.log(`Connecting to ${config.host}:${config.port} with TLS=${config.tls}`) ``` -------------------------------- ### Usenet Streamer Startup Sequence Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/MODULES.md Illustrates the step-by-step initialization process of the Usenet Streamer application, from loading environment variables to starting the Express server. ```bash node server.js ├─→ [server.js] require('dotenv').config() │ └─→ Load .env file │ ├─→ [config/runtimeEnv.js] applyRuntimeEnv() │ └─→ Load runtime-env.json if exists │ ├─→ [server.js] Unhandled error handlers │ ├─→ process.on('uncaughtException', ...) │ └─→ process.on('unhandledRejection', ...) │ ├─→ Express setup │ ├─→ CORS middleware │ ├─→ Security headers │ └─→ Routes registration │ ├─→ [services] Load all services │ ├─→ indexer.js │ ├─→ nzbdav.js │ ├─→ newznab.js │ ├─→ triage/ │ └─→ cache/ │ ├─→ [server.js] ensureSharedSecret() or use setup HTML │ └─→ Require ADDON_SHARED_SECRET for operation │ ├─→ [server.js] ensureStreamTokenExists() │ └─→ Auto-generate ADDON_STREAM_TOKEN if missing │ ├─→ [services] Optional: preWarmNntpPool() │ └─→ If TRIAGE_ENABLED, initialize pool early │ └─→ app.listen(PORT) └─→ Server ready, accepting requests ``` -------------------------------- ### GET /assets/* Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Static asset serving (icons, stylesheets). ```APIDOC ## GET /assets/* ### Description Static asset serving (icons, stylesheets). ### Method GET ### Endpoint /assets/... ### Example GET /assets/icon.png ``` -------------------------------- ### Install Caddy Web Server Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/beginners-guide.md Installs the Caddy web server on Debian-based systems. This is used to serve UsenetStreamer with HTTPS. ```bash sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl -fsSL https://dl.cloudsmith.io/public/caddy/stable/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | sudo tee /etc/apt/sources.list.d/caddy-stable.list sudo apt update sudo apt install -y caddy ``` -------------------------------- ### Disk Cache Statistics Example Usage Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md An example demonstrating how to retrieve disk cache statistics and log the percentage of disk space used. It also includes a conditional check to clear the cache if it's nearing its maximum capacity. ```javascript const stats = getDiskCacheStats() console.log(`Disk cache: ${(stats.percentUsed).toFixed(1)}% full`) if (stats.totalBytes > stats.maxBytes * 0.9) { clearDiskCache('space low') } ``` -------------------------------- ### Stream Response Example Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Example of a successful response when requesting available streams, detailing stream quality, URL, size, and behavior hints. ```json { "streams": [ { "title": "1080p | x264 | AAC | Group [cached]", "url": "http://nzbdav:3000/webdav/path/to/file.mkv", "externalUrl": "https://your-addon-domain/stream/token/", "size": 4000000000, "downloaded": 24, "tag": "cached", "behaviorHints": { "bingeGroup": "1080p", "proxyHeaders": {} } } ] } ``` -------------------------------- ### Parse Release Metadata Example Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/RELEASE-PARSER.md Demonstrates how to use the parseReleaseMetadata function with a sample release title and logs the extracted metadata. ```javascript const metadata = parseReleaseMetadata('The.Shawshank.Redemption.1994.2160p.BluRay.x265.10bit.HDR.AAC-Group') ``` -------------------------------- ### Disk NZB Cache Set Example Usage Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md An example demonstrating how to store NZB data in the disk cache and log the path where it was cached. This is useful for persisting NZB files for later retrieval. ```javascript const path = setDiskCacheFile(nzbKey, nzbData) console.log(`Cached NZB at ${path}`) ``` -------------------------------- ### Disk NZB Cache Example Usage Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md An example demonstrating how to retrieve an NZB file from the disk cache, check its existence, and read its data. This is useful for using cached NZB files during triage. ```javascript const cached = getDiskCacheFile(nzbKey) if (cached && fs.existsSync(cached)) { console.log(`Using cached NZB: ${cached}`) const data = fs.readFileSync(cached) return data } ``` -------------------------------- ### Example: Querying Indexers for Movie Releases Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/INDEXER-SERVICE.md Demonstrates how to define search plans for movie releases and query indexers with custom options like timeout and deduplication. ```javascript const plans = [ { type: 'movie', query: 'tt0944947' }, { type: 'movie', query: 'Game of Thrones 2011' } ] const results = await queryIndexers(plans, { timeout: 45000, deduplicate: true }) ``` -------------------------------- ### NZBDav Stream Cache Example Usage Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md An example demonstrating how to retrieve an NZBDav stream path and construct a stream object if the path is found in the cache. ```javascript const viewPath = getNzbdavStreamPath(normalized) if (viewPath) { console.log(`Instant stream available: ${viewPath}`) const stream = { url: `${WEBDAV_URL}${viewPath}` } return stream } ``` -------------------------------- ### Reset UsenetStreamer Configuration Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/windows-native-setup.md To start fresh, stop and remove the container, then remove the configuration volume. Afterward, re-run the initial Docker command. ```powershell docker stop usenetstreamer docker rm usenetstreamer docker volume rm usenetstreamer_config ``` -------------------------------- ### Request Validation Error Example Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ERRORS.md An example JSON response for missing or invalid request parameters. ```json { "error": "Missing or invalid parameters", "details": { "missing": ["type", "id"] } } ``` -------------------------------- ### Error Response Example Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Example of an error response, typically indicating a server-side issue or configuration problem. ```json { "error": "Configuration error or service unavailable", "details": { "type": "movie", "id": "tt0944947", "timestamp": "2026-05-22T10:30:00Z" } } ``` -------------------------------- ### Stream NZB using NZBDAV Service Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/NZBDAV-SERVICE.md This example demonstrates how to queue an NZB for download using the NZBDAV service, poll for its completion, and retrieve a playback URL. Ensure NZBDav is configured before use. ```javascript const nzbdavService = require('./src/services/nzbdav') async function streamNzb(nzbUrl, contentTitle) { try { // Ensure NZBDav is configured nzbdavService.ensureNzbdavConfigured() // Queue the NZB for download console.log('Queuing NZB...') const category = nzbdavService.getNzbdavCategory('movie') const job = await nzbdavService.queueNzbToNzbdav( nzbUrl, category, contentTitle ) console.log(`Queued as job ${job.id}`) // Poll for completion console.log('Waiting for download...') const completed = await nzbdavService.pollForNzbdavCompletion(job.id, { timeout: 240000, // 4 minutes interval: 1000 }) console.log(`Download complete! Files:`) completed.files.forEach(f => console.log(` - ${f.name} (${f.size} bytes)`)) // Return playback URL const playbackUrl = `${process.env.NZBDAV_WEBDAV_URL}${completed.files[0].viewPath}` return { url: playbackUrl } } catch (error) { console.error('Failed to stream:', error.message) throw error } } // Usage streamNzb('https://indexer.com/nzb/12345.nzb', '1080p Movie') .then(stream => console.log(`Play: ${stream.url}`)) .catch(console.error) ``` -------------------------------- ### Example Configuration Error Response Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ERRORS.md Illustrates the structure of an error response when configuration is missing or invalid. Includes error type, ID, and timestamp. ```json { "error": "Configuration error or service unavailable", "details": { "type": "movie", "id": "tt0111161", "timestamp": "2026-05-22T10:30:00Z" } } ``` -------------------------------- ### GET /admin/:token/admin/ Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Web dashboard for configuration and credential management. ```APIDOC ## GET /admin/:token/admin/ ### Description Web dashboard for configuration and credential management. ### Method GET ### Endpoint /:adminToken/admin/ ### Features - View and edit all runtime settings - Test connections (Prowlarr, NZBHydra, NZBDav, NNTP) - Manage credentials securely (write-only, never exposed in responses) - Trigger addon restart ### Security Protected by: `ADDON_SHARED_SECRET` (admin token) ``` -------------------------------- ### File Size Caching Example Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/NZBDAV-SERVICE.md Illustrates the usage of a file size caching mechanism with a 30-minute Time-To-Live (TTL). This avoids redundant probes for files whose sizes are already known. ```javascript const cached = getCachedFileSize(urlKey) if (cached) return cached setCachedFileSize(urlKey, size) ``` -------------------------------- ### Runtime Configuration Persistence File Format Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Example JSON structure for the runtime-env.json file, used to persist configuration changes made in the admin panel. ```json { "ADDON_BASE_URL": "https://my-addon.example.com", "INDEXER_MANAGER": "prowlarr", "NZB_SORT_ORDER": "quality,size,files" } ``` -------------------------------- ### Language Detection Examples Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/RELEASE-PARSER.md Illustrates how `parseReleaseMetadata` detects single and multiple languages from release titles. Shows the resulting language arrays. ```javascript const tamil = parseReleaseMetadata('Movie.2024.1080p.BluRay.Tamil.x264-Group') console.log(tamil.languages) // ["Tamil"] const multilang = parseReleaseMetadata('Show.2024.1080p.WebRip.English.Hindi.AAC-Group') console.log(multilang.languages) // ["English", "Hindi"] ``` -------------------------------- ### Launch Docker Compose Services Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/beginners-guide.md Pulls the latest Docker images and starts the services defined in the docker-compose.yml file in detached mode. ```bash docker compose pull docker compose up -d ``` -------------------------------- ### Basic Release Metadata Parsing Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/RELEASE-PARSER.md Demonstrates how to use the `parseReleaseMetadata` function to extract title, resolution, quality, codec, languages, and group from a release string. Shows example output. ```javascript const { parseReleaseMetadata } = require('./src/services/metadata/releaseParser') const title = 'The.Matrix.1999.2160p.BluRay.x265.10bit.HDR.AAC-GROUP' const parsed = parseReleaseMetadata(title) console.log(`Title: ${parsed.title}`) console.log(`Resolution: ${parsed.resolution}`) console.log(`Quality: ${parsed.quality}`) console.log(`Codec: ${parsed.codec}`) console.log(`Languages: ${parsed.languages.join(', ')}`) console.log(`Group: ${parsed.group}`) ``` -------------------------------- ### GET /manifest.json Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Retrieves the Stremio addon manifest, which describes the addon's capabilities, supported content types, and other metadata. ```APIDOC ## GET /manifest.json ### Description Returns the Stremio addon manifest describing capabilities and supported content types. ### Method GET ### Endpoint /manifest.json /:token/manifest.json ### Response (200 OK) ```json { "id": "com.usenet.streamer", "version": "1.7.11", "name": "UsenetStreamer", "description": "Usenet-powered instant streams...", "logo": "https://your-addon-domain/assets/icon.png", "resources": ["stream", "catalog", "meta"], "types": ["movie", "series", "channel", "tv"], "catalogs": [], "idPrefixes": ["tt", "tvdb", "tmdb", "kitsu", "mal", "anilist", "pt"] } ``` ### Response Schema | Field | Type | Description | |-------|------|-------------| | id | string | Unique addon identifier; `com.usenet.streamer.native` if `STREAMING_MODE=native` | | version | string | Addon version (e.g., "1.7.11") | | name | string | Display name (defaults to "UsenetStreamer") | | description | string | Addon description; varies by streaming mode | | logo | string | Logo URL | | resources | string[] | Supported resources; includes "stream", optionally "catalog" and "meta" | | types | string[] | Content types: movie, series, channel, tv | | catalogs | object[] | Catalog definitions (empty if `NZBDAV_HISTORY_CATALOG_LIMIT <= 0` or native mode) | | idPrefixes | string[] | ID prefixes handled by addon | ``` -------------------------------- ### Basic Triage Flow Example Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/TRIAGE-SERVICE.md Illustrates a basic triage flow, including configuring NNTP settings, running the triage and rank process, and formatting the results. This is useful for understanding the core usage of the triage service. ```javascript const { triageAndRank } = require('./src/services/triage/runner') const { buildTriageNntpConfig } = require('./src/services/triage/nntpConfig') async function getHealthCheckedStreams(results) { // Configure NNTP const nntpConfig = buildTriageNntpConfig() // Run triage const triaged = await triageAndRank(results, { timeout: 35000, maxParallel: 8, nntpConfig, healthMethod: 'stat', statSampleCount: 1 }) // Return verified + unverified (but skip blocked) const approved = [...triaged.verified, ...triaged.unverified] return approved.map(item => ({ result: item.result, verdict: item.verdict, streamTitle: `${item.result.title} [${item.verdict.status}]` })) } ``` -------------------------------- ### Start and Monitor Background Triage Session Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/TRIAGE-SERVICE.md Initiates a background triage session and demonstrates how to check its progress and retrieve ready results. Ensure necessary configurations and callbacks are provided. ```javascript const bgSession = backgroundTriage.startSession(contentKey, { results, nzbdavQueue, nntpConfig, onProgress: (progress) => { console.log(`Triaging: ${progress.evaluated}/${progress.total}`) } }) // Later, check progress const progress = bgSession.getProgress() console.log(`Verified: ${progress.verified}, Blocked: ${progress.blocked}`) // Get first ready NZB const ready = bgSession.peekReady() if (ready) { console.log(`Stream ready: ${ready.title}`) } ``` -------------------------------- ### Pre-warm NNTP connection pool Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/TRIAGE-SERVICE.md Pre-initialize the shared NNTP connection pool for faster triage startup. This example shows how to call the function and handle potential errors during warmup. ```javascript await preWarmNntpPool() ``` ```javascript // Called on addon startup if triage enabled if (process.env.NZB_TRIAGE_ENABLED === 'true') { preWarmNntpPool().catch(err => { console.warn('NNTP pool warmup failed (non-fatal):', err.message) }) } ``` -------------------------------- ### Initialize WebDAV Client Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/NZBDAV-SERVICE.md This snippet shows how to create a WebDAV client instance using the 'webdav' npm package. It requires the WebDAV URL, username, and password to be configured. ```javascript const { createClient } = await import('webdav') const client = createClient(NZBDAV_WEBDAV_URL, { username: NZBDAV_WEBDAV_USER, password: NZBDAV_WEBDAV_PASS }) ``` -------------------------------- ### Configure Smart Play Mode Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Determine when to offer Smart Play streams based on NZB readiness. ```bash NZB_SMART_PLAY_MODE=any-candidate ``` -------------------------------- ### Newznab/Prowlarr RSS Item Example Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/TYPES.md An example of a single item from a Newznab or Prowlarr RSS feed, detailing its structure including title, link, publication date, and custom Newznab attributes like size and file count. This structure is parsed into the NzbResult type. ```xml Release Title https://indexer/nzb/12345.nzb 12345 Fri, 22 May 2026 10:30:00 GMT 5000 ``` -------------------------------- ### Run UsenetStreamer Container on Windows Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/windows-native-setup.md This command downloads the UsenetStreamer image, creates and configures a container for native streaming, and sets it to auto-restart. Ensure you replace 'MySecretToken123' with a strong, unique token. ```powershell docker run -d \ --name usenetstreamer \ --restart unless-stopped \ -p 7000:7000 \ -v usenetstreamer_config:/app/config \ -e STREAMING_MODE=native \ -e ADDON_BASE_URL=http://localhost:7000 \ -e ADDON_SHARED_SECRET=MySecretToken123 \ ghcr.io/sanket9225/usenetstreamer:latest ``` -------------------------------- ### Create Docker Compose Folders Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/beginners-guide.md Creates necessary directories for NZBDav and UsenetStreamer configuration. Adjust PUID/PGID if your user ID is not 1000. ```bash mkdir -p ~/usenetstack/{nzbdav,usenetstreamer-config} mkdir -p ~/usenetstack/prowlarr # only if you still plan to run Prowlarr/NZBHydra locally cd ~/usenetstack ``` -------------------------------- ### GET /nzb/:token Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md NZB download endpoint for NZB-only streaming mode or preview functionality. ```APIDOC ## GET /nzb/:token ### Description NZB download endpoint for NZB-only streaming mode or preview functionality. ### Method GET ### Endpoint /nzb/:nzbUrl ### Parameters #### Query Parameters - **from** (string) - Optional - Indexer identifier for user-agent selection ### Response #### Success Response (200) Binary NZB file or redirect to original indexer URL #### Status Codes - `200` — NZB served - `302` — Redirect to upstream indexer - `404` — NZB not found - `500` — Download error ``` -------------------------------- ### GET /stream/:type/:id.json Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Returns available streams for the requested content. This is the primary endpoint called by Stremio. ```APIDOC ## GET /stream/:type/:id.json ### Description Returns available streams for the requested content. This is the primary endpoint called by Stremio. ### Method GET ### Endpoint /stream/:type/:id.json ### Parameters #### Path Parameters - **type** (string) - Required - Content type: `movie` or `series` - **id** (string) - Required - Content identifier (IMDb: `tt` prefix, TVDb: `tvdb:`, TMDb: `tmdb:`, anime: `kitsu:`/`mal:`/`anilist:`, special: custom prefixes) #### Query Parameters - **lang** (string) - Optional - Preferred language (e.g., `de`, `en-US`) - **extra** (string) - Optional - Stremio extra parameters ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200 OK) - **streams** (object[]) - Array of available streams - **streams[].title** (string) - Display title with quality/codec/group info; includes tags like `[cached]`, `✅ verified`, `⚠️ unverified`, `🚫 blocked`, `⚡ instant` - **streams[].url** (string) - Direct WebDAV/NZBDav playback URL or NZB download URL - **streams[].externalUrl** (string) - Proxied URL if streaming via addon (conditional) - **streams[].size** (number) - File size in bytes (optional) - **streams[].downloaded** (number) - Download progress percentage (optional; 0-100) - **streams[].tag** (string) - Visual tag (e.g., `cached`, `premium`) - **streams[].behaviorHints** (object) - Stremio behavior hints - **streams[].behaviorHints.bingeGroup** (string) - Auto-play grouping key - **streams[].behaviorHints.proxyHeaders** (object) - Headers for proxy mode #### Response Example ```json { "streams": [ { "title": "1080p | x264 | AAC | Group [cached]", "url": "http://nzbdav:3000/webdav/path/to/file.mkv", "externalUrl": "https://your-addon-domain/stream/token/...", "size": 4000000000, "downloaded": 24, "tag": "cached", "behaviorHints": { "bingeGroup": "1080p", "proxyHeaders": {} } } ] } ``` #### Error Response (5xx) ```json { "error": "Configuration error or service unavailable", "details": { "type": "movie", "id": "tt0944947", "timestamp": "2026-05-22T10:30:00Z" } } ``` ``` -------------------------------- ### Configure Direct Newznab Indexers Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md List direct Newznab indexer URLs and API keys sequentially using NEWZNAB_1, NEWZNAB_2, etc. ```bash NEWZNAB_1=https://api.nzbgeek.info|your-api-key ``` ```bash NEWZNAB_2=https://api.tabula-rasa.wtf|your-api-key ``` -------------------------------- ### Enable NEWZNAB_ENABLED Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Set to 'true' to enable direct Newznab indexer support, bypassing Prowlarr/NZBHydra. ```bash NEWZNAB_ENABLED=true ``` -------------------------------- ### GET /stream/:type/:id.json Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Provides streaming information for a given content type and ID. This is a public route and requires configuration. ```APIDOC ## GET /stream/:type/:id.json ### Description Provides streaming information for a given content type and ID. This is a public route and requires configuration. ### Method GET ### Endpoint /stream/:type/:id.json /:token/stream/:type/:id.json ``` -------------------------------- ### Set Configuration Directory Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Specify the directory for persisting runtime configuration. Defaults to './config'. ```bash CONFIG_DIR=/data/config ``` -------------------------------- ### Handle Critical Errors Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/MODULES.md Logs critical errors to the console with a [tag] prefix and returns a 503 Service Unavailable response with setup instructions. ```javascript Log to console with [tag] prefix Return 503 with setup instructions ``` -------------------------------- ### Run Tests Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/README.md Execute the project's tests using npm. Note that tests for the bundled title parser library are not yet implemented. ```bash npm test # Not implemented; tests for parse-torrent-title in src/utils/lib/ ``` -------------------------------- ### Get Available Streams Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Retrieve available streams for a given content type and ID. This is the primary endpoint used by Stremio for content playback. ```http GET /stream/:type/:id.json GET /:token/stream/:type/:id.json ``` -------------------------------- ### GET /meta/:type/:id.json Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Fetches detailed metadata for a specific content item, primarily used in conjunction with the NZBDav catalog feature. ```APIDOC ## GET /meta/:type/:id.json ### Description Returns detailed metadata for a specific content item (used by NZBDav catalog). ### Method GET ### Endpoint /meta/:type/:id.json /:token/meta/:type/:id.json ### Response (200 OK) ```json { "meta": { "id": "nzbdav:normalized-title-12345", "type": "movie", "name": "Movie Title", "poster": "https://..." } } ``` ``` -------------------------------- ### Initialize NNTP Pool with Servers Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/TRIAGE-SERVICE.md Demonstrates initializing an NNTP connection pool using an array of server objects. This is typically done after building the server array. ```javascript const servers = buildNntpServersArray(triageConfig) const pool = new NNTPPool(servers) ``` -------------------------------- ### Stream Object JSON Response Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/README.md Example JSON response for a stream request. It includes stream details like title, URL, size, and tag. ```json { "streams": [ { "title": "1080p | x264 | AAC | GROUP [cached]", "url": "http://nzbdav:3000/webdav/Movies/file.mkv", "size": 4000000000, "tag": "cached" } ] } ``` -------------------------------- ### Set STREAMING_MODE Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Choose the streaming mode: 'addon' for WebDAV/NZBDav or 'native' for NZB download mode with Windows native player support. ```bash STREAMING_MODE=addon ``` -------------------------------- ### Get Stream Response from Cache Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md Retrieves a cached stream response using a content key. Returns null if the item is not found in the cache or has expired. ```javascript const cached = getStreamResponse('movie:tt0111161') ``` ```javascript const cacheKey = `${type}:${id}` const cached = getStreamResponse(cacheKey) if (cached) { console.log(`Using cached response with ${cached.streams.length} streams`) return cached } ``` -------------------------------- ### GET /catalog/:type/:id.json Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/ENDPOINTS.md Retrieves catalog entries for completed NZBDav downloads. This endpoint supports pagination via the 'skip' query parameter. ```APIDOC ## GET /catalog/:type/:id.json ### Description Returns catalog entries for completed NZBDav downloads (optional feature). ### Method GET ### Endpoint /catalog/:type/:id.json /:token/catalog/:type/:id.json ### Parameters #### Query Parameters - **skip** (number) - Optional - Number of entries to skip for pagination ### Response (200 OK) ```json { "metas": [ { "id": "nzbdav:normalized-title-12345", "type": "movie", "name": "Movie Title (1080p)", "poster": "https://..." } ] } ``` ### Response Schema | Field | Type | Description | |-------|------|-------------| | metas | object[] | Array of metadata objects | | metas[].id | string | Unique identifier (prefixed with `nzbdav:`) | | metas[].type | string | Content type: movie or series | | metas[].name | string | Display name with resolution/quality badges | | metas[].poster | string | Poster image URL (optional) | ### Status Codes - `200` — Success - `500` — NZBDav not configured or connection failed ``` -------------------------------- ### Enable NZBDav Stream Prefetch HEAD Requests Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Enable HEAD requests to prefetch NZBDav file sizes, which can speed up streaming. ```bash NZBDAV_STREAM_PREFETCH_HEAD=true ``` -------------------------------- ### Set Node Environment Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Define the Node.js environment. Options are 'development' or 'production'. Defaults to 'production'. ```bash NODE_ENV=production ``` -------------------------------- ### Get Last Fetched History Entry Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/NZBDAV-SERVICE.md Returns metadata about the most recently fetched NZBDav history. This includes the timestamp of the fetch and the count of entries retrieved. ```javascript const lastFetch = getLastFetchedHistoryEntry() ``` ```javascript { timestamp: number, // Unix timestamp count: number // Number of entries fetched } ``` ```javascript const meta = getLastFetchedHistoryEntry() console.log(`Last history fetch: ${new Date(meta.timestamp).toISOString()}`) ``` -------------------------------- ### preWarmNntpPool() Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/TRIAGE-SERVICE.md Pre-initializes the shared NNTP connection pool to ensure faster triage operations when the service starts. This is an asynchronous operation that does not return any value upon completion. ```APIDOC ## preWarmNntpPool() ### Description Pre-initialize the shared NNTP connection pool for faster triage startup. ### Parameters None ### Request Example ```javascript // Called on addon startup if triage enabled if (process.env.NZB_TRIAGE_ENABLED === 'true') { preWarmNntpPool().catch(err => { console.warn('NNTP pool warmup failed (non-fatal):', err.message) }) } ``` ### Response #### Success Response (200) void #### Response Example None ``` -------------------------------- ### Check Container Logs Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/windows-native-setup.md Use this command to view the logs of the 'usenetstreamer' Docker container. This is helpful for diagnosing startup issues. ```powershell docker logs usenetstreamer ``` -------------------------------- ### Connect to VPS via SSH Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/beginners-guide.md Connect to your Virtual Private Server using SSH. Replace 'your-vps-ip' with your server's actual IP address. ```bash ssh root@your-vps-ip ``` -------------------------------- ### Get All Cache Statistics Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md Retrieves statistics from all cache layers, including stream, NZB, NZBDav, and disk caches. Useful for monitoring cache performance and usage. ```javascript const allStats = getAllCacheStats() ``` ```javascript const stats = getAllCacheStats() console.log('Cache Statistics:') console.log(` Streams: ${stats.stream.size} entries (${stats.stream.avgHitRate}% hit rate)`) console.log(` NZBs: ${stats.nzb.verified} verified, ${stats.nzb.blocked} blocked`) console.log(` NZBDav: ${stats.nzbdav.size} mounted, last updated ${stats.nzbdav.lastRefresh}`) console.log(` Disk: ${(stats.disk.percentUsed).toFixed(1)}% full`) ``` -------------------------------- ### Configure TVDb API Key Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Enter your TVDb API v4 key. ```bash TVDB_API_KEY=your-tvdb-api-key ``` -------------------------------- ### Docker Deployment Source: https://github.com/sanket9225/usenetstreamer/blob/master/README.md Deploys UsenetStreamer using Docker. Ensure the configuration directory is created beforehand. The ADDON_SHARED_SECRET is used for admin access. ```bash mkdir -p ~/usenetstreamer-config docker run -d --restart unless-stopped \ --name usenetstreamer \ --log-opt max-size=10m \ --log-opt max-file=1 \ -p 7000:7000 \ -e ADDON_SHARED_SECRET=super-secret-token \ -e CONFIG_DIR=/data/config \ -v ~/usenetstreamer-config:/data/config \ ghcr.io/sanket9225/usenetstreamer:latest ``` -------------------------------- ### Evict stale NNTP pool connections Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/TRIAGE-SERVICE.md Closes stale NNTP pool connections after inactivity timeout. This example demonstrates how to periodically call the function to clean up idle connections. ```javascript evictStaleSharedNntpPool() ``` ```javascript // Called periodically to clean up idle connections setInterval(() => { evictStaleSharedNntpPool() }, 5 * 60 * 1000) ``` -------------------------------- ### Set NZBDAV_API_KEY Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Enter the API key for authenticating with your NZBDav instance. ```bash NZBDAV_API_KEY=your-nzbdav-api-key ``` -------------------------------- ### UsenetStreamer Data Flow Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/README.md Illustrates the data flow from a Stremio client request to the final NZBDav stream, detailing the intermediate steps involving indexer search, release parsing, health checks, and caching. ```mermaid graph TD A[Stremio Client] B(GET /stream/:type/:id.json) C[Indexer Search (Prowlarr/NZBHydra/Newznab)] D[Release Parsing & Filtering] E[Optional: Health Checks (NNTP)] F[Formatting & Caching] G[Response with NZBDav URLs] H[User clicks → NZBDav queues → WebDAV streams] A --> B --> C --> D --> E --> F --> G --> H ``` -------------------------------- ### Get Stream Cache Statistics Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md Retrieves statistics for the stream response cache, including size, hits, misses, and average hit rate. This helps in monitoring cache performance. ```javascript const stats = getStreamCacheStats() ``` ```javascript const stats = getStreamCacheStats() console.log(`Cache hit rate: ${stats.avgHitRate}%`) ``` -------------------------------- ### Create .env file for Secrets Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/beginners-guide.md Generates a .env file to store secrets, specifically the ADDON_SECRET, by reading from a generated .shared-secret file. ```bash cat <<'EOF' > .env ADDON_SECRET=$(cat .shared-secret) EOF ``` -------------------------------- ### Set Resolution Limit Per Quality Tier Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Cap the number of results shown per resolution tier. For example, setting it to '4' limits to 4 results per resolution. ```bash NZB_RESOLUTION_LIMIT_PER_QUALITY=4 ``` -------------------------------- ### Enable Easynews Integration Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Enable direct integration with Easynews, which acts as a built-in indexer. ```bash EASYNEWS_ENABLED=true ``` -------------------------------- ### Configure TMDb API Key Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Enter your TMDb API key obtained from their developer portal. ```bash TMDB_API_KEY=your-tmdb-api-key ``` -------------------------------- ### Get Verified NZB Triage Decision Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md Retrieves the cached triage decision for a given NZB URL. The decision includes status, verdict, and timestamp, and may include a reason if blocked. ```javascript const decision = getVerifiedNzb('https://indexer.com/nzb/12345.nzb') ``` ```javascript const verdict = getVerifiedNzb(nzbUrl) if (verdict) { console.log(`Cached verdict: ${verdict.status}`) if (verdict.status === 'blocked') { console.warn(`Reason: ${verdict.reason}`) } } ``` -------------------------------- ### Docker Compose Configuration for UsenetStreamer Stack Source: https://github.com/sanket9225/usenetstreamer/blob/master/docs/beginners-guide.md Defines services for NZBDav and UsenetStreamer, including image, ports, environment variables, and volumes. Ensure 'ADDON_BASE_URL' is set correctly for public access. ```yaml version: "3.9" services: nzbdav: image: nzbdav/nzbdav:alpha container_name: nzbdav restart: unless-stopped ports: - "3000:3000" environment: - PUID=1000 - PGID=1000 volumes: - ./nzbdav:/config usenetstreamer: image: ghcr.io/sanket9225/usenetstreamer:latest container_name: usenetstreamer restart: unless-stopped depends_on: - nzbdav ports: - "7000:7000" environment: ADDON_SHARED_SECRET: Enter-some-random-string-here-as-token ADDON_BASE_URL: https://your-duckdns-subdomain.duckdns.org/ NZBDAV_URL: http://nzbdav:3000 NZBDAV_WEBDAV_URL: http://nzbdav:3000 CONFIG_DIR: /data/config volumes: - ./usenetstreamer-config:/data/config # Notes: # - Keep `ADDON_BASE_URL` secret-free; the addon automatically appends `/your-secret/` when serving manifests. # - All API keys, Easynews credentials, and direct Newznab endpoints can be entered later via the admin dashboard. # - Want to keep Prowlarr/NZBHydra? Add another service block and set `INDEXER_MANAGER_URL`/`API_KEY` env vars. # - `CONFIG_DIR` tells UsenetStreamer to persist `runtime-env.json` under `/data/config`, which is the host bind mount you just created. ``` -------------------------------- ### Enable TLS for NNTP Connections Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Configure whether to use TLS for secure NNTP connections. ```bash NZB_TRIAGE_NNTP_TLS=true ``` -------------------------------- ### Get Verified NZB Cache Statistics Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md Retrieves statistics about the NZB verdict cache, including the number of cached decisions and their verification status. Use this to monitor the state of the NZB verdict cache. ```javascript const stats = getVerifiedNzbCacheStats() ``` -------------------------------- ### Get NZBDav Category for Content Type Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/NZBDAV-SERVICE.md Resolves the appropriate NZBDav category name based on the content type. It maps 'movie' and 'series' to specific configuration variables and uses a default for others. ```javascript const category = getNzbdavCategory('movie') ``` ```javascript const movieCat = getNzbdavCategory('movie') // "Movies" const tvCat = getNzbdavCategory('series') // "Tv" ``` -------------------------------- ### Configure NZB Naming Pattern Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Set a custom pattern for naming NZBs and tracking history using available tokens. ```bash NZB_NAMING_PATTERN="{title} | {stream_quality} | {group}" ``` -------------------------------- ### Set NZBDAV_URL Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/CONFIGURATION.md Provide the base URL for your NZBDav instance API. Ensure no trailing slash. ```bash NZBDAV_URL=http://localhost:3000 ``` -------------------------------- ### Get Disk Cache Statistics Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md Retrieves statistics about the disk cache, including the number of cached files, total bytes used, maximum allowed bytes, and the percentage of disk space used. The maximum size is configurable. ```javascript const stats = getDiskCacheStats() ``` -------------------------------- ### Get NZBDav Cache Statistics Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/CACHE-SYSTEM.md Retrieves statistics about the NZBDav stream cache, including the number of cached paths, the last refresh time, and the total number of refreshes. Use this to monitor the NZBDav cache's activity. ```javascript const stats = getNzbdavCacheStats() ``` -------------------------------- ### ensureNzbdavConfigured Source: https://github.com/sanket9225/usenetstreamer/blob/master/_autodocs/api-reference/NZBDAV-SERVICE.md Ensures that the NZBDav service is configured. Throws an error if any required configuration is missing. ```APIDOC ## ensureNzbdavConfigured() ### Description Throws an error if NZBDav is not properly configured. ### Method Not applicable (function call) ### Parameters None ### Throws - Error: `NZBDAV_URL is not configured` - Error: `NZBDAV_API_KEY is not configured` - Error: `NZBDAV_WEBDAV_USER is not configured` - Error: `NZBDAV_WEBDAV_PASS is not configured` ### Example ```javascript try { ensureNzbdavConfigured() // Safe to use NZBDav } catch (error) { res.status(500).json({ error: error.message }) } ``` ### Source `src/services/nzbdav.js` ```