MCPcopy
hub / github.com/iptv-org/iptv / drawTable

Function drawTable

scripts/commands/playlist/test.ts:114–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112}
113
114function drawTable() {
115 process.stdout.write('\u001b[3J\u001b[1J')
116 console.clear()
117
118 const streamsGrouped = streams.groupBy((stream: Stream) => stream.filepath)
119 for (const filepath of streamsGrouped.keys()) {
120 const streams: Stream[] = streamsGrouped.get(filepath) || []
121
122 const table = new CliTable({
123 columns: [
124 { name: '', alignment: 'center', minLen: 3, maxLen: 3 },
125 { name: 'tvg-id', alignment: 'left', color: 'green', minLen: 25, maxLen: 25 },
126 { name: 'url', alignment: 'left', color: 'green', minLen: 100, maxLen: 100 },
127 { name: 'label', alignment: 'left', color: 'yellow', minLen: 13, maxLen: 13 },
128 { name: 'status', alignment: 'left', minLen: 25, maxLen: 25 }
129 ]
130 })
131
132 streams.forEach((stream: Stream, index: number) => {
133 const tvgId = truncate(stream.getTvgId(), 25)
134 const url = truncate(stream.url, 100)
135 const color = getColor(stream)
136 const label = stream.label || ''
137 const status = stream.statusCode || 'PENDING'
138
139 const row = {
140 '': index,
141 'tvg-id': chalk[color](tvgId),
142 url: chalk[color](url),
143 label: chalk[color](label),
144 status: chalk[color](status)
145 }
146 table.append(row)
147 })
148
149 process.stdout.write(`\n${chalk.underline(filepath)}\n`)
150
151 process.stdout.write(table.toString())
152 }
153}
154
155async function removeBrokenLinks() {
156 const streamsGrouped = streams.groupBy((stream: Stream) => stream.filepath)

Callers 2

mainFunction · 0.85
onFinishFunction · 0.85

Calls 5

appendMethod · 0.95
toStringMethod · 0.95
truncateFunction · 0.90
getColorFunction · 0.85
getTvgIdMethod · 0.80

Tested by

no test coverage detected