From f0e25ddce8a782f477d3596dfa6002b18b72fcbb Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 16 Oct 2021 23:21:10 +0300 Subject: [PATCH] Update update-readme.js --- scripts/update-readme.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/update-readme.js b/scripts/update-readme.js index 705af49d..1cf1f9cf 100644 --- a/scripts/update-readme.js +++ b/scripts/update-readme.js @@ -15,11 +15,17 @@ async function main() { if (!country) return const epg = file.read(filename) const parsed = parser.parse(epg) + let emptyGuides = 0 + parsed.channels.forEach(channel => { + const showCount = parsed.programs.filter(p => p.channel === channel.id).length + if (showCount === 0) emptyGuides++ + }) data.push({ countryFlag: country.flag, countryName: country.name, guideUrl: filename.replace('.gh-pages', 'https://iptv-org.github.io/epg'), - channelCount: parsed.channels.length + channelCount: parsed.channels.length, + emptyGuides }) }) @@ -32,7 +38,7 @@ async function main() { }) console.log('Generating table...') - const table = generateTable(data, ['Country', 'Channels', 'EPG']) + const table = generateTable(data, ['Country', 'Channels', 'EPG', 'Status']) file.write('.readme/_table.md', table) console.log('Updating README.md...') markdownInclude.compileFiles('.readme/config.json') @@ -57,10 +63,13 @@ function generateTable(data, header) { let root = output.indexOf(item.countryName) === -1 const rowspan = root && size > 1 ? ` rowspan="${size}"` : '' const name = item.countryName + let status = '🟢' + if (item.emptyGuides === item.channelCount) status = '🔴' + else if (item.emptyGuides > 0) status = '🟡' const cell1 = root ? `${item.countryFlag} ${name}` : '' - output += `\t\t${cell1}${item.channelCount}${item.guideUrl}\n` + output += `\t\t${cell1}${item.channelCount}${item.guideUrl}${status}\n` } output += '\t\n'