From 6b7092f53ddb1f4a27d3e365a19b35df3e0e2711 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 8 Nov 2021 14:54:53 +0300 Subject: [PATCH] Create orange.fr.config.js --- sites/orange.fr/orange.fr.config.js | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sites/orange.fr/orange.fr.config.js diff --git a/sites/orange.fr/orange.fr.config.js b/sites/orange.fr/orange.fr.config.js new file mode 100644 index 00000000..2664c590 --- /dev/null +++ b/sites/orange.fr/orange.fr.config.js @@ -0,0 +1,49 @@ +const dayjs = require('dayjs') + +module.exports = { + site: 'orange.fr', + url({ channel, date }) { + return `https://rp-ott-mediation-tv.woopic.com/api-gw/live/v3/applications/STB4PC/programs?groupBy=channel&includeEmptyChannels=false&period=${date.valueOf()},${date + .add(1, 'd') + .valueOf()}&after=${channel.site_id}&limit=1` + }, + logo({ channel }) { + return channel.logo + }, + parser: function ({ content, channel }) { + let programs = [] + const items = parseItems(content, channel) + items.forEach(item => { + const start = parseStart(item) + const stop = parseStop(item, start) + programs.push({ + title: item.title, + category: item.genreDetailed, + description: item.synopsis, + icon: parseIcon(item), + start: start.toJSON(), + stop: stop.toJSON() + }) + }) + + return programs + } +} + +function parseIcon(item) { + return item.covers && item.covers.length ? item.covers[0].url : null +} + +function parseStart(item) { + return dayjs.unix(item.diffusionDate) +} + +function parseStop(item, start) { + return start.add(item.duration, 's') +} + +function parseItems(content, channel) { + const data = JSON.parse(content) + + return data && data[channel.site_id] ? data[channel.site_id] : [] +}