mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 10:00:05 -04:00
Update scripts
This commit is contained in:
parent
1ff81f25ac
commit
9be9b2ba6a
5 changed files with 217 additions and 4 deletions
27
scripts/core/streamTester.ts
Normal file
27
scripts/core/streamTester.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue