mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update update-readme.ts
This commit is contained in:
parent
74d32668ec
commit
dcf7794caa
1 changed files with 15 additions and 17 deletions
|
@ -33,7 +33,8 @@ type Guide = {
|
||||||
flag: string
|
flag: string
|
||||||
url: string
|
url: string
|
||||||
channelCount: number
|
channelCount: number
|
||||||
emptyGuides: number
|
programCount: number
|
||||||
|
errorCount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
@ -46,26 +47,23 @@ async function main() {
|
||||||
const guidesByCanadaProvince: Guide[] = []
|
const guidesByCanadaProvince: Guide[] = []
|
||||||
files.forEach((filename: string) => {
|
files.forEach((filename: string) => {
|
||||||
console.log(`Loading '${filename}'...`)
|
console.log(`Loading '${filename}'...`)
|
||||||
const matches: string[] = filename.match(/\.gh\-pages\/guides\/(.*)\/.*/i) || []
|
const [_, code, site]: string[] = filename.match(
|
||||||
const code: string | undefined = matches[1]
|
/\.gh\-pages\/guides\/(.*)\/(.*)\.epg\.xml/i
|
||||||
if (code === undefined) return
|
) || ['', '', '']
|
||||||
|
if (!code || !site) return
|
||||||
|
|
||||||
const xml = file.read(filename)
|
const xml: string = file.read(filename)
|
||||||
let epg: EPG = parser.parse(xml)
|
const epg: EPG = parser.parse(xml)
|
||||||
let emptyGuides = 0
|
|
||||||
if (!epg.channels.length) return
|
const log = file.read(`logs/${site}_${code}.log`)
|
||||||
epg.channels.forEach((channel: Channel) => {
|
const errorCount = (log.match(/ERROR/gi) || []).length
|
||||||
const showCount = epg.programs.filter(
|
|
||||||
(program: Program) => program.channel === channel.id
|
|
||||||
).length
|
|
||||||
if (showCount === 0) emptyGuides++
|
|
||||||
})
|
|
||||||
|
|
||||||
const guide: Guide = {
|
const guide: Guide = {
|
||||||
flag: '',
|
flag: '',
|
||||||
url: filename.replace('.gh-pages', 'https://iptv-org.github.io/epg'),
|
url: filename.replace('.gh-pages', 'https://iptv-org.github.io/epg'),
|
||||||
channelCount: epg.channels.length,
|
channelCount: epg.channels.length,
|
||||||
emptyGuides
|
programCount: epg.programs.length,
|
||||||
|
errorCount
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code.startsWith('us-')) {
|
if (code.startsWith('us-')) {
|
||||||
|
@ -138,8 +136,8 @@ function generateTable(guides: Guide[], header: string[]) {
|
||||||
let root = output.indexOf(name) === -1
|
let root = output.indexOf(name) === -1
|
||||||
const rowspan = root && size > 1 ? ` rowspan="${size}"` : ''
|
const rowspan = root && size > 1 ? ` rowspan="${size}"` : ''
|
||||||
let status = '🟢'
|
let status = '🟢'
|
||||||
if (guide.emptyGuides === guide.channelCount) status = '🔴'
|
if (guide.programCount === 0) status = '🔴'
|
||||||
else if (guide.emptyGuides > 0) status = '🟡'
|
else if (guide.errorCount > 0) status = '🟡'
|
||||||
const cell1 = root ? `<td align="left" valign="top" nowrap${rowspan}>${name}</td>` : ''
|
const cell1 = root ? `<td align="left" valign="top" nowrap${rowspan}>${name}</td>` : ''
|
||||||
output += `\t\t<tr>${cell1}<td align="right" nowrap>${guide.channelCount}</td><td align="left" nowrap><code>${guide.url}</code></td><td align="center">${status}</td></tr>\n`
|
output += `\t\t<tr>${cell1}<td align="right" nowrap>${guide.channelCount}</td><td align="left" nowrap><code>${guide.url}</code></td><td align="center">${status}</td></tr>\n`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue