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
620 B
TypeScript
28 lines
620 B
TypeScript
4 months ago
|
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/test_results/all.js')).default
|
||
|
|
||
|
return results[stream.url]
|
||
|
} else {
|
||
|
return this.checker.checkStream({
|
||
|
url: stream.url,
|
||
|
http: {
|
||
|
referrer: stream.httpReferrer,
|
||
|
'user-agent': stream.httpUserAgent
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|