Update scripts

This commit is contained in:
freearhey 2025-03-15 07:31:10 +03:00
parent 1ff81f25ac
commit 9be9b2ba6a
5 changed files with 217 additions and 4 deletions

21
scripts/core/cliTable.ts Normal file
View 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()
}
}

View file

@ -7,3 +7,5 @@ export * from './issueParser'
export * from './htmlTable'
export * from './apiClient'
export * from './issueData'
export * from './streamTester'
export * from './cliTable'

View file

@ -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)
}

View 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
}
})
}
}
}