From 8471163f665869d678f0c93b91c98d77a2af12cc Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 28 Oct 2022 00:53:47 +0300 Subject: [PATCH] Update update.js --- scripts/commands/guides/update.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/commands/guides/update.js b/scripts/commands/guides/update.js index 8f54307d..37e82df9 100644 --- a/scripts/commands/guides/update.js +++ b/scripts/commands/guides/update.js @@ -146,9 +146,7 @@ function getChannelPrograms(programs) { let priority = 0 let selected for (let site in sites) { - let prog = sites[site][0] - - let sitePriority = calcPriority(prog) + let sitePriority = calcPriority(sites[site]) if (sitePriority > priority) { selected = site @@ -159,17 +157,19 @@ function getChannelPrograms(programs) { return sites[selected] || [] } -function calcPriority(program) { +function calcPriority(programs) { let priority = 0 - for (let prop in program) { - let value = program[prop] + for (let program of programs) { + for (let prop in program) { + let value = program[prop] - if (Array.isArray(value) && value.length) { - priority++ - } else if (typeof value === 'string' && value) { - priority++ - } else if (value && typeof value === 'object' && Object.values(value).map(Boolean).length) { - priority++ + if (Array.isArray(value) && value.length) { + priority++ + } else if (typeof value === 'string' && value) { + priority++ + } else if (value && typeof value === 'object' && Object.values(value).map(Boolean).length) { + priority++ + } } }