diff --git a/.docs/content/2.essentials/1.targets.md b/.docs/content/2.essentials/1.targets.md index 9bbae05..8e8607a 100644 --- a/.docs/content/2.essentials/1.targets.md +++ b/.docs/content/2.essentials/1.targets.md @@ -10,5 +10,5 @@ A target is the device on which the stream will be played. #### Possible targets - **`targets.BROWSER`** Stream will be played in a browser with CORS - **`targets.BROWSER_EXTENSION`** Stream will be played in a browser using the p-stream extension (WIP) -- **`targets.NATIVE`** Stream will be played on a native video player +- **`targets.NATIVE`** Stream will be played on a native video player (includes MKV-capable sources) - **`targets.ANY`** No restrictions for selecting streams, will just give all of them diff --git a/.docs/content/3.in-depth/5.flags.md b/.docs/content/3.in-depth/5.flags.md index c7fe4a7..b35a140 100644 --- a/.docs/content/3.in-depth/5.flags.md +++ b/.docs/content/3.in-depth/5.flags.md @@ -12,6 +12,7 @@ Sometimes a source will block netlify or cloudflare. Making self hosted proxies - **`IP_LOCKED`**: The streams are locked by IP: requester and watcher must be the same. - **`CF_BLOCKED`**: *(Cosmetic)* Indicates the source/embed blocks Cloudflare IPs. For actual enforcement, remove `CORS_ALLOWED` or add `IP_LOCKED`. - **`PROXY_BLOCKED`**: *(Cosmetic)* Indicates streams shouldn't be proxied. For actual enforcement, remove `CORS_ALLOWED` or add `IP_LOCKED`. +- **`MKV_REQUIRED`**: The stream is MKV format and requires a player that supports it. Most browsers cannot play MKV; use this flag so browser targets filter these out. Native and desktop/mobile apps with proper players receive these streams when using the `native` target. ## How Flags Affect Target Compatibility @@ -40,6 +41,11 @@ Sometimes a source will block netlify or cloudflare. Making self hosted proxies - 🏷️ Informational label indicating proxy incompatibility - ⚠️ **Still requires removing `CORS_ALLOWED` or adding `IP_LOCKED` for actual enforcement** +**With `MKV_REQUIRED`:** +- ❌ Browser targets (most browsers cannot play MKV) +- ✅ Extension targets (depends on player) +- ✅ Native targets (desktop/mobile apps with proper players can play MKV) + ### Provider-Level Flags Impact **With `CORS_ALLOWED`:** @@ -148,13 +154,13 @@ return { }] }; -// IP-locked streams (when you specifically need consistent IP) +// MKV streams (native/desktop/mobile apps with proper players only; filtered out for browser) return { stream: [{ id: 'primary', - type: 'hls', - playlist: 'https://example.com/playlist.m3u8', - flags: [flags.IP_LOCKED], // Prevents proxy usage when IP consistency required + type: 'file', + qualities: { 1080: { type: 'mp4', url: 'https://example.com/video.mkv' } }, + flags: [flags.MKV_REQUIRED], // Browser disallows; native target enables these sources captions: [] }] }; diff --git a/src/__test__/standard/utils/features.test.ts b/src/__test__/standard/utils/features.test.ts index 75a855c..730f95f 100644 --- a/src/__test__/standard/utils/features.test.ts +++ b/src/__test__/standard/utils/features.test.ts @@ -134,4 +134,25 @@ describe('flagsAllowedInFeatures()', () => { false, ); }); + + it('should disallow MKV_REQUIRED for browser target (disallowed in features)', () => { + checkFeatures( + { requires: [flags.CORS_ALLOWED], disallowed: [flags.MKV_REQUIRED] }, + [flags.CORS_ALLOWED, flags.MKV_REQUIRED], + false, + ); + checkFeatures( + { requires: [flags.CORS_ALLOWED], disallowed: [flags.MKV_REQUIRED] }, + [flags.CORS_ALLOWED], + true, + ); + }); + + it('should allow MKV_REQUIRED for native target (no disallowed)', () => { + checkFeatures( + { requires: [], disallowed: [] }, + [flags.MKV_REQUIRED], + true, + ); + }); }); diff --git a/src/entrypoint/utils/targets.ts b/src/entrypoint/utils/targets.ts index b3e4200..a337647 100644 --- a/src/entrypoint/utils/targets.ts +++ b/src/entrypoint/utils/targets.ts @@ -13,6 +13,10 @@ export const flags = { // Streams and sources with this flag wont be proxied // And will be exclusive to the extension PROXY_BLOCKED: 'proxy-blocked', + + // The stream is MKV format and requires a player that supports it. + // Most browsers cannot play MKV; native/desktop/mobile apps with proper players can. + MKV_REQUIRED: 'mkv-required', } as const; export type Flags = (typeof flags)[keyof typeof flags]; @@ -41,11 +45,11 @@ export type FeatureMap = { export const targetToFeatures: Record = { browser: { requires: [flags.CORS_ALLOWED], - disallowed: [], + disallowed: [flags.MKV_REQUIRED], }, 'browser-extension': { requires: [], - disallowed: [], + disallowed: [flags.MKV_REQUIRED], }, native: { requires: [], @@ -53,7 +57,7 @@ export const targetToFeatures: Record = { }, any: { requires: [], - disallowed: [], + disallowed: [flags.MKV_REQUIRED], }, };