mirror of
https://github.com/p-stream/providers.git
synced 2026-03-11 09:45:36 +00:00
add MKV feature flag
This commit is contained in:
parent
e66b7a2982
commit
47ec40bfb9
4 changed files with 39 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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: []
|
||||
}]
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<Targets, FeatureMap> = {
|
||||
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<Targets, FeatureMap> = {
|
|||
},
|
||||
any: {
|
||||
requires: [],
|
||||
disallowed: [],
|
||||
disallowed: [flags.MKV_REQUIRED],
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue