From 7445722a2240d3f083db97942af3922b3e379039 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sat, 25 Jan 2025 22:11:32 +0300 Subject: [PATCH] Create yes.co.il.config.js --- sites/yes.co.il/yes.co.il.config.js | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sites/yes.co.il/yes.co.il.config.js diff --git a/sites/yes.co.il/yes.co.il.config.js b/sites/yes.co.il/yes.co.il.config.js new file mode 100644 index 00000000..c32e433d --- /dev/null +++ b/sites/yes.co.il/yes.co.il.config.js @@ -0,0 +1,57 @@ +const axios = require('axios') + +module.exports = { + site: 'yes.co.il', + days: 2, + url({ channel, date }) { + return `https://svc.yes.co.il/api/content/broadcast-schedule/channels/${ + channel.site_id + }?date=${date.format('YYYY-M-D')}&ignorePastItems=true` + }, + request: { + headers: { + 'user-agent': + 'Mozilla/5.0 (Linux; Linux x86_64) AppleWebKit/600.3 (KHTML, like Gecko) Chrome/48.0.2544.291 Safari/600' + } + }, + parser({ content }) { + const items = parseItems(content) + + return items.map(item => ({ + title: item.title, + description: item.description, + image: item.imageUrl, + start: item.starts, + stop: item.ends + })) + }, + async channels() { + const data = await axios.get( + 'https://svc.yes.co.il/api/content/broadcast-schedule/channels?page=0&pageSize=1000', + { + headers: { + 'accept-language': 'he-IL', + 'user-agent': + 'Mozilla/5.0 (Linux; Linux x86_64) AppleWebKit/600.3 (KHTML, like Gecko) Chrome/48.0.2544.291 Safari/600' + } + } + ) + + return data.items.map(channel => ({ + lang: 'he', + name: channel.title, + site_id: channel.channelId + })) + } +} + +function parseItems(content) { + try { + const data = JSON.parse(content) + if (!data || !Array.isArray(data.items)) return [] + + return data.items + } catch { + return [] + } +}