diff --git a/sites/mbc.net/mbc.net.config.js b/sites/mbc.net/mbc.net.config.js new file mode 100644 index 00000000..9bb86374 --- /dev/null +++ b/sites/mbc.net/mbc.net.config.js @@ -0,0 +1,42 @@ +const dayjs = require('dayjs') + +module.exports = { + site: 'mbc.net', + url({ date, channel }) { + return `https://www.mbc.net/.rest/api/channel/grids?from=${date.valueOf()}&to=${date + .add(1, 'd') + .valueOf()}&channel=${channel.site_id}` + }, + logo({ channel }) { + return channel.logo + }, + parser: function ({ content, channel, date }) { + let programs = [] + const items = parseItems(content) + items.forEach(item => { + programs.push({ + title: item.showPageTitle, + category: item.showPageGenreInArabic, + description: item.showPageAboutInArabic, + start: parseStart(item), + stop: parseStop(item) + }) + }) + + return programs + } +} + +function parseStart(item) { + return dayjs(item.startTime).toJSON() +} + +function parseStop(item) { + return dayjs(item.endTime).toJSON() +} + +function parseItems(content) { + const data = JSON.parse(content) + + return data +}