From 6e45494617b63b066f6f650b92aaa7081c80d1ee Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 12 Sep 2022 07:35:46 +0300 Subject: [PATCH] Update update.js --- scripts/commands/readme/update.js | 34 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/scripts/commands/readme/update.js b/scripts/commands/readme/update.js index b197c5f9b7..003a60b89f 100644 --- a/scripts/commands/readme/update.js +++ b/scripts/commands/readme/update.js @@ -47,15 +47,27 @@ async function createCountryTable() { logger.info('creating country table...') const rows = [] await api.countries.load() + await api.subdivisions.load() const items = await parser.parseLogs(`${LOGS_DIR}/countries.log`) for (const item of items) { const code = file.getFilename(item.filepath) const country = await api.countries.find({ code: code.toUpperCase() }) - rows.push({ - name: country ? `${country.flag} ${country.name}` : 'Undefined', - channels: item.count, - playlist: `https://iptv-org.github.io/iptv/${item.filepath}` - }) + if (country) { + rows.push({ + name: `${country.flag} ${country.name}`, + channels: item.count, + playlist: `https://iptv-org.github.io/iptv/${item.filepath}` + }) + } else { + const subdivision = await api.subdivisions.find({ code: code.toUpperCase() }) + if (subdivision) { + rows.push({ + name: `      ${subdivision.name}`, + channels: item.count, + playlist: `https://iptv-org.github.io/iptv/${item.filepath}` + }) + } + } } const table = createTable(rows, [ @@ -99,11 +111,13 @@ async function createRegionTable() { for (const item of items) { const code = file.getFilename(item.filepath) const region = await api.regions.find({ code: code.toUpperCase() }) - rows.push({ - name: region ? region.name : 'Undefined', - channels: item.count, - playlist: `https://iptv-org.github.io/iptv/${item.filepath}` - }) + if (region) { + rows.push({ + name: region.name, + channels: item.count, + playlist: `https://iptv-org.github.io/iptv/${item.filepath}` + }) + } } const table = createTable(rows, [