mirror of
https://github.com/iptv-org/iptv
synced 2025-12-19 11:57:30 -05:00
Update test.ts
This commit is contained in:
@@ -127,20 +127,24 @@ function drawTable() {
|
|||||||
{ name: '', alignment: 'center', minLen: 3, maxLen: 3 },
|
{ name: '', alignment: 'center', minLen: 3, maxLen: 3 },
|
||||||
{ name: 'tvg-id', alignment: 'left', color: 'green', minLen: 25, maxLen: 25 },
|
{ name: 'tvg-id', alignment: 'left', color: 'green', minLen: 25, maxLen: 25 },
|
||||||
{ name: 'url', alignment: 'left', color: 'green', minLen: 100, maxLen: 100 },
|
{ name: 'url', alignment: 'left', color: 'green', minLen: 100, maxLen: 100 },
|
||||||
{ name: 'label', alignment: 'left', color: 'yellow', minLen: 15, maxLen: 15 },
|
{ name: 'label', alignment: 'left', color: 'yellow', minLen: 13, maxLen: 13 },
|
||||||
{ name: 'status', alignment: 'left', minLen: 25, maxLen: 25 }
|
{ name: 'status', alignment: 'left', minLen: 25, maxLen: 25 }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
streams.forEach((stream: Stream, index: number) => {
|
streams.forEach((stream: Stream, index: number) => {
|
||||||
const key = stream.getUniqKey()
|
const tvgId = truncate(stream.getTvgId(), 25)
|
||||||
const tvgId = stream.getTvgId()
|
const url = truncate(stream.url, 100)
|
||||||
|
const color = getColor(stream)
|
||||||
|
const label = stream.label || ''
|
||||||
|
const status = stream.statusCode || 'PENDING'
|
||||||
|
|
||||||
const row = {
|
const row = {
|
||||||
'': index,
|
'': index,
|
||||||
'tvg-id': truncate(tvgId, 25),
|
'tvg-id': chalk[color](tvgId),
|
||||||
url: truncate(stream.url, 100),
|
url: chalk[color](url),
|
||||||
label: stream.label,
|
label: chalk[color](label),
|
||||||
status: getStatus(stream)
|
status: chalk[color](status)
|
||||||
}
|
}
|
||||||
table.append(row)
|
table.append(row)
|
||||||
})
|
})
|
||||||
@@ -199,13 +203,12 @@ async function isOffline() {
|
|||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus(stream: Stream): string {
|
function getColor(stream: Stream): string {
|
||||||
if (!stream.statusCode) return chalk.gray('PENDING')
|
if (!stream.statusCode) return 'gray'
|
||||||
if (stream.statusCode === 'OK') return chalk.green(stream.statusCode)
|
if (stream.statusCode === 'OK') return 'green'
|
||||||
if (errorStatusCodes.includes(stream.statusCode) && !stream.label)
|
if (errorStatusCodes.includes(stream.statusCode) && !stream.label) return 'red'
|
||||||
return chalk.red(stream.statusCode)
|
|
||||||
|
|
||||||
return chalk.yellow(stream.statusCode)
|
return 'yellow'
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBroken(stream: Stream): boolean {
|
function isBroken(stream: Stream): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user