mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 18:13:25 +00:00
check validity of stream before returning
This commit is contained in:
17
src/utils/valid.ts
Normal file
17
src/utils/valid.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Stream } from '@/providers/streams';
|
||||
|
||||
export function isValidStream(stream: Stream | undefined): boolean {
|
||||
if (!stream) return false;
|
||||
if (stream.type === 'hls') {
|
||||
if (!stream.playlist) return false;
|
||||
return true;
|
||||
}
|
||||
if (stream.type === 'file') {
|
||||
const validQualities = Object.values(stream.qualities).filter((v) => v.url.length > 0);
|
||||
if (validQualities.length === 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// unknown file type
|
||||
return false;
|
||||
}
|
Reference in New Issue
Block a user