mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 14:53:24 +00:00
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@movie-web/providers",
|
"name": "@movie-web/providers",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "Package that contains all the providers of movie-web",
|
"description": "Package that contains all the providers of movie-web",
|
||||||
"main": "./lib/index.umd.js",
|
"main": "./lib/index.umd.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
55
src/__test__/utils/valid.test.ts
Normal file
55
src/__test__/utils/valid.test.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { makeStandardFetcher } from "@/fetchers/standardFetch";
|
||||||
|
import { makeProviders } from "@/main/builder";
|
||||||
|
import { targets } from "@/main/targets";
|
||||||
|
import { isValidStream } from "@/utils/valid";
|
||||||
|
import fetch from "node-fetch";
|
||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
|
||||||
|
describe('isValidStream()', () => {
|
||||||
|
it('should pass valid streams', () => {
|
||||||
|
expect(isValidStream({
|
||||||
|
type: "file",
|
||||||
|
flags: [],
|
||||||
|
qualities: {
|
||||||
|
"1080": {
|
||||||
|
type: "mp4",
|
||||||
|
url: "hello-world"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})).toBe(true);
|
||||||
|
expect(isValidStream({
|
||||||
|
type: "hls",
|
||||||
|
flags: [],
|
||||||
|
playlist: "hello-world"
|
||||||
|
})).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should detect empty qualities', () => {
|
||||||
|
expect(isValidStream({
|
||||||
|
type: "file",
|
||||||
|
flags: [],
|
||||||
|
qualities: {}
|
||||||
|
})).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should detect empty stream urls', () => {
|
||||||
|
expect(isValidStream({
|
||||||
|
type: "file",
|
||||||
|
flags: [],
|
||||||
|
qualities: {
|
||||||
|
"1080": {
|
||||||
|
type: "mp4",
|
||||||
|
url: "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should detect emtpy HLS playlists', () => {
|
||||||
|
expect(isValidStream({
|
||||||
|
type: "hls",
|
||||||
|
flags: [],
|
||||||
|
playlist: "",
|
||||||
|
})).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
@@ -80,7 +80,7 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
|
|||||||
...contextBase,
|
...contextBase,
|
||||||
media: ops.media,
|
media: ops.media,
|
||||||
});
|
});
|
||||||
if (!isValidStream(output?.stream)) {
|
if (output?.stream && !isValidStream(output?.stream)) {
|
||||||
throw new NotFoundError('stream is incomplete');
|
throw new NotFoundError('stream is incomplete');
|
||||||
}
|
}
|
||||||
if (output?.stream && !flagsAllowedInFeatures(ops.features, output.stream.flags)) {
|
if (output?.stream && !flagsAllowedInFeatures(ops.features, output.stream.flags)) {
|
||||||
|
Reference in New Issue
Block a user