Official OMSS backend framework - Multi-provider streaming media aggregation framework with auto-discovery
npm install @omss/framework@omss/framework?@omss/framework is the official TypeScript/Node.js implementation framework that makes building OMSS-compliant backends effortless. Instead of manually implementing the specification from scratch, developers can focus solely on writing provider scraping logic while the framework handles all the boilerplate β routing, validation, proxy management, caching, error handling, and response formatting.
bash
npm
npm install @omss/framework
yarn
yarn add @omss/framework
pnpm
pnpm add @omss/framework
`
π Quick start
Minimal example using the builtβin provider and inβmemory cache:
`ts
// src/server.ts
import { OMSSServer } from '@omss/framework';
import { ExampleProvider } from './src/providers/implementations/example-provider';
// Create server instance
const server = new OMSSServer({
name: 'My OMSS Backend',
version: '1.0.0',
host: 'localhost',
port: 3000,
cache: {
type: 'memory',
ttl: {
sources: 7200,
subtitles: 7200,
},
},
tmdb: {
apiKey: process.env.TMDB_API_KEY,
cacheTTL: 86400,
},
});
// Register providers
const registry = server.getRegistry();
registry.register(new ExampleProvider());
// or use the very cool auto-discovery feature
// registry.discoverProviders('./path/to/providerfolder');
// Note: this is relative to where you start the server.
// Start server
await server.start();
`
.env:
`env
TMDB_API_KEY=your_tmdb_key_here
HOST=localhost
PORT=3000
NODE_ENV=development
`
Run in dev:
`bash
npx tsx src/server.ts
`
And then it should work!
βοΈ Configuration
$3
`typescript
interface OMSSConfig {
// Required: Server identification
name: string; // Your server name
version: string; // OMSS Spec version
// Optional: Network settings
host?: string; // Default: 'localhost'
port?: number; // Default: 3000
publicUrl?: string; // For reverse proxy setups
// Optional: Cache configuration
cache?: {
type: 'memory' | 'redis';
ttl: {
sources: number;
subtitles: number;
};
redis?: {
host: string;
port: number;
password?: string;
};
};
// Required: TMDB configuration
tmdb?: {
apiKey?: string; // Can also use TMDB_API_KEY env var
cacheTTL?: number; // Default: 86400 (24 hours)
};
}
`
$3
#### Development
`typescript
const server = new OMSSServer({
name: 'OMSS Dev Server',
version: '1.0.0',
host: 'localhost',
port: 3000,
cache: {
type: 'memory',
ttl: {
sources: 7200,
subtitles: 7200,
},
},
tmdb: {
apiKey: process.env.TMDB_API_KEY,
cacheTTL: 86400,
},
});
`
#### Production with Redis
`typescript
const server = new OMSSServer({
name: 'OMSS Production',
version: '1.0.0',
host: '0.0.0.0',
port: 3000,
publicUrl: 'https://api.mystream.com',
cache: {
type: 'redis',
ttl: {
sources: 7200,
subtitles: 7200,
},
redis: {
host: process.env.REDIS_HOST || 'localhost',
port: parseInt(process.env.REDIS_PORT || '6379'),
password: process.env.REDIS_PASSWORD,
},
},
tmdb: {
apiKey: process.env.TMDB_API_KEY,
cacheTTL: 86400,
},
});
`
#### Behind Reverse Proxy
`typescript
const server = new OMSSServer({
name: 'OMSS API',
version: '1.0.0',
host: '0.0.0.0',
port: 3000,
// This is the public URL clients will use
publicUrl: 'https://myapp.com/api',
cache: {
type: 'redis',
redis: {
host: 'redis.internal',
port: 6379,
},
},
tmdb: {
apiKey: process.env.TMDB_API_KEY,
cacheTTL: 86400,
},
});
`
π Creating Custom Providers
See the detailed Provider Creation Guide for a complete walkthrough.
$3
The easiest way to add a new provider:
1. Create a directory for all of your provider files
`bash
touch src/providers/implementations/my-provider.ts
`
2. Implement the BaseProvider class (see example below) in each file.
3. In the Setup, use the discoverProviders method of the ProviderRegistry to load all providers from that directory:
`typescript
const registry = server.getRegistry();
registry.discoverProviders('./src/providers/implementations'); // relative to where you start the server from
`
4. That's it! The provider will be automatically discovered and registered when you start the server!
No imports, no manual registration needed!
$3
`typescript
import { BaseProvider } from './src/providers/base-provider';
import { ProviderCapabilities, ProviderMediaObject, ProviderResult } from './src/core/types';
export class MyProvider extends BaseProvider {
// Required: Provider identification
readonly id = 'my-provider';
readonly name = 'My Provider';
readonly enabled = true;
// Required: Base URL and headers
readonly BASE_URL = 'https://provider.example.com';
readonly HEADERS = {
'User-Agent': 'Mozilla/5.0',
Referer: 'https://provider.example.com',
};
// Required: Declare what this provider supports
readonly capabilities: ProviderCapabilities = {
supportedContentTypes: ['movies', 'tv'],
};
// Implement movie scraping
async getMovieSources(media: ProviderMediaObject): Promise {
this.console.log('Fetching movie sources', media);
try {
// Your scraping logic here
const streamUrl = await this.scrapeMovieUrl(media.tmdbId); // this is just some example function
return {
sources: [
{
url: this.createProxyUrl(streamUrl, this.HEADERS),
type: 'hls',
quality: '1080p',
audioTracks: [
{
language: 'en',
label: 'English',
},
],
provider: {
id: this.id,
name: this.name,
},
},
],
subtitles: [],
diagnostics: [],
};
} catch (error) {
this.console.error('Failed to fetch sources', error, media);
return {
sources: [],
subtitles: [],
diagnostics: [
{
code: 'PROVIDER_ERROR',
message: ${this.name} failed,
field: '',
severity: 'error',
},
],
};
}
}
// Implement TV scraping
async getTVSources(media: ProviderMediaObject): Promise {
// Similar to getMovieSources but for TV
return { sources: [], subtitles: [], diagnostics: [] };
}
// Optional: Custom health check
async healthCheck(): Promise {
try {
const response = await fetch(this.BASE_URL);
return response.ok;
} catch {
return false;
}
}
}
`
$3
See the detailed Provider Creation Guide for a complete walkthrough.
π‘ API Endpoints
$3
Fetch streaming sources for a movie.
Parameters:
- tmdbId (path): TMDB movie ID
Response:
`json
{
"responseId": "uuid-v4",
"expiresAt": "2026-01-18T20:00:00.000Z",
"sources": [
{
"url": "/v1/proxy?data=...",
"type": "hls",
"quality": "1080p",
"audioTracks": [
{
"language": "en",
"label": "English"
}
],
"provider": {
"id": "vixsrc",
"name": "VixSrc"
}
}
],
"subtitles": [],
"diagnostics": []
}
`
$3
Fetch streaming sources for a TV episode.
Parameters:
- tmdbId (path): TMDB series ID
- season (path): Season number (0-99)
- episode (path): Episode number (1-9999)
Response: Same structure as movies endpoint
$3
Proxy streaming URLs with custom headers.
Query Parameters:
- data (required): URL-encoded JSON containing:
`json
{
"url": "https://stream.example.com/video.m3u8",
"headers": {
"Referer": "https://provider.example.com"
}
}
`
$3
Force refresh cached sources.
Parameters:
- responseId (path): Response ID from previous request
$3
Health check endpoint.
Response:
`json
{
"status": "healthy",
"version": "1.0.0",
"providers": {
"total": 1,
"enabled": 1
}
}
`
π Environment Variables
`env
Server Configuration
PORT=3000 # Port number for the server
HOST=0.0.0.0 # Use 'localhost' to restrict to local access
NODE_ENV=development # 'development' | 'production'
TMDB Configuration
TMDB_API_KEY=your_tmdb_api_key_here
TMDB_CACHE_TTL=86400
Cache Configuration
CACHE_TYPE=memory # 'memory' | 'redis'
Redis Configuration (if using Redis cache)
REDIS_HOST=localhost # default Redis host
REDIS_PORT=6379 # default Redis port
REDIS_PASSWORD= # Redis password if required
`
ποΈ Architecture
`
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OMSS Server β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Controllers β
β βββ ContentController (Movies/TV endpoints) β
β βββ ProxyController (Streaming proxy) β
β βββ HealthController (Health checks) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Services β
β βββ SourceService (Aggregates provider results) β
β βββ TMDBService (Validates against TMDB) β
β βββ ProxyService (Handles URL proxying) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Provider Registry β
β βββ Manages all registered providers β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Providers (Implement BaseProvider) β
β βββ YourCustomProvider β
β βββ ... β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Cache Layer β
β βββ MemoryCache (Development) β
β βββ RedisCache (Production) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
``