From 1a2237b0a1d30af9c6c4211f4530819fba28f47b Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 31 Jan 2022 04:20:14 +0300 Subject: [PATCH] Update update-guides.js --- scripts/commands/update-guides.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/commands/update-guides.js b/scripts/commands/update-guides.js index ca77c78e..fc322fe3 100644 --- a/scripts/commands/update-guides.js +++ b/scripts/commands/update-guides.js @@ -24,6 +24,7 @@ async function generateGuides() { await api.channels.load() for (const key in grouped) { + const [__, site] = key.split('/') const filepath = `${PUBLIC_DIR}/guides/${key}.epg.xml` let items = grouped[key] @@ -44,21 +45,23 @@ async function generateGuides() { } const programs = await loadProgramsForItems(items) + let channels = Object.keys(_.groupBy(programs, 'channel')) logger.info(`Creating "${filepath}"...`) - const channels = items - .map(item => { - const channel = api.channels.find({ id: item.channel.xmltv_id }) + channels = channels + .map(id => { + const channel = api.channels.find({ id }) if (!channel) return null return { id: channel.id, display_name: channel.name, - url: item.channel.site, + url: site, icon: channel.logo } }) .filter(i => i) + const output = grabber.convertToXMLTV({ channels, programs }) await file.create(filepath, output)