From 33a21ddfef80a8463dc3b51ce13ce72c2750b9b7 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 4 Mar 2022 18:16:19 +0300 Subject: [PATCH] Update delta.nl.config.js --- sites/delta.nl/delta.nl.config.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sites/delta.nl/delta.nl.config.js b/sites/delta.nl/delta.nl.config.js index e3be8d1a..90cbfbf1 100644 --- a/sites/delta.nl/delta.nl.config.js +++ b/sites/delta.nl/delta.nl.config.js @@ -8,17 +8,19 @@ module.exports = { .add(1, 'd') .unix()}&includeDetails=true&channels=${channel.site_id}` }, - parser: function ({ content, channel }) { + async parser({ content, channel }) { let programs = [] const items = parseItems(content, channel) - items.forEach(item => { + for (let item of items) { + const details = await loadProgramDetails(item) programs.push({ title: item.title, icon: item.images.thumbnail.url, + description: details.description, start: parseStart(item).toJSON(), stop: parseStop(item).toJSON() }) - }) + } return programs }, @@ -40,6 +42,17 @@ module.exports = { } } +async function loadProgramDetails(item) { + if (!item.ID) return {} + const url = `https://clientapi.tv.delta.nl/guide/4/details/${item.ID}?X-Response-Version=4.5` + const data = await axios + .get(url) + .then(r => r.data) + .catch(console.log) + + return data || {} +} + function parseStart(item) { return dayjs.unix(item.start) }