mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 01:50:04 -04:00
Update scripts
This commit is contained in:
parent
1ff81f25ac
commit
9be9b2ba6a
5 changed files with 217 additions and 4 deletions
21
scripts/core/cliTable.ts
Normal file
21
scripts/core/cliTable.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { Table } from 'console-table-printer'
|
||||
|
||||
export class CliTable {
|
||||
table: Table
|
||||
|
||||
constructor(options?) {
|
||||
this.table = new Table(options)
|
||||
}
|
||||
|
||||
append(row) {
|
||||
this.table.addRow(row)
|
||||
}
|
||||
|
||||
render() {
|
||||
this.table.printTable()
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.table.render()
|
||||
}
|
||||
}
|
|
@ -7,3 +7,5 @@ export * from './issueParser'
|
|||
export * from './htmlTable'
|
||||
export * from './apiClient'
|
||||
export * from './issueData'
|
||||
export * from './streamTester'
|
||||
export * from './cliTable'
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Collection, Storage } from '@freearhey/core'
|
||||
import parser from 'iptv-playlist-parser'
|
||||
import { Stream } from '../models'
|
||||
import path from 'path'
|
||||
import { STREAMS_DIR } from '../constants'
|
||||
|
||||
export class PlaylistParser {
|
||||
storage: Storage
|
||||
|
@ -15,8 +13,7 @@ export class PlaylistParser {
|
|||
let streams = new Collection()
|
||||
|
||||
for (const filepath of files) {
|
||||
const relativeFilepath = filepath.replace(path.normalize(STREAMS_DIR), '')
|
||||
const _streams: Collection = await this.parseFile(relativeFilepath)
|
||||
const _streams: Collection = await this.parseFile(filepath)
|
||||
streams = streams.concat(_streams)
|
||||
}
|
||||
|
||||
|
|
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