mirror of https://github.com/iptv-org/iptv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
635 B
TypeScript
28 lines
635 B
TypeScript
import { Stream } from '../models'
|
|
import { IPTVChecker } from 'iptv-checker'
|
|
import { TESTING } from '../constants'
|
|
|
|
export class StreamTester {
|
|
checker: IPTVChecker
|
|
|
|
constructor() {
|
|
this.checker = new IPTVChecker()
|
|
}
|
|
|
|
async test(stream: Stream) {
|
|
if (TESTING) {
|
|
const results = (await import('../../tests/__data__/input/playlist_test/results.js')).default
|
|
|
|
return results[stream.url]
|
|
} else {
|
|
return this.checker.checkStream({
|
|
url: stream.url,
|
|
http: {
|
|
referrer: stream.getHttpReferrer(),
|
|
'user-agent': stream.getHttpUserAgent()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|