From a02e3db46a5b458c932c8555346a1db6b9b19a05 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 2 Aug 2021 21:55:58 +0300 Subject: [PATCH] Update format.js --- scripts/format.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/format.js b/scripts/format.js index 095f7346a..fb77cab20 100644 --- a/scripts/format.js +++ b/scripts/format.js @@ -12,7 +12,7 @@ async function main() { log.print(`\nProcessing '${playlist.url}'...`) await parser .parsePlaylist(playlist.url) - .then(addMissingData) + .then(formatPlaylist) .then(playlist => { if (file.read(playlist.url) !== playlist.toString()) { log.print('updated') @@ -27,24 +27,26 @@ async function main() { log.finish() } -async function addMissingData(playlist) { +async function formatPlaylist(playlist) { for (const channel of playlist.channels) { const code = file.getBasename(playlist.url) - // tvg-name + // add missing tvg-name if (!channel.tvg.name && code !== 'unsorted' && channel.name) { channel.tvg.name = channel.name.replace(/\"/gi, '') } - // tvg-id + // add missing tvg-id if (!channel.tvg.id && code !== 'unsorted' && channel.tvg.name) { const id = utils.name2id(channel.tvg.name) channel.tvg.id = id ? `${id}.${code}` : '' } - // country + // add missing country if (!channel.countries.length) { const name = utils.code2name(code) channel.countries = name ? [{ code, name }] : [] channel.tvg.country = channel.countries.map(c => c.code.toUpperCase()).join(';') } + // update group-title + channel.group.title = channel.category } return playlist