From 575000e0f3d29b8195796605df2aa9d70243757d Mon Sep 17 00:00:00 2001 From: theofficialomega <30985701+BellezaEmporium@users.noreply.github.com> Date: Mon, 23 Feb 2026 01:50:03 +0100 Subject: [PATCH] . --- sites/syn.is/syn.is.config.js | 57 +++++++++++++++++++---------------- sites/syn.is/syn.is.test.js | 4 +-- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/sites/syn.is/syn.is.config.js b/sites/syn.is/syn.is.config.js index 5bb2a0f3..d2e6cbb0 100644 --- a/sites/syn.is/syn.is.config.js +++ b/sites/syn.is/syn.is.config.js @@ -15,37 +15,42 @@ module.exports = { url({ channel, date }) { return `https://www.syn.is/api/epg/${channel.site_id}/${date.format('YYYY-MM-DD')}` }, - parser: function ({ content }) { - let data - try { - data = JSON.parse(content) - } catch (error) { - console.error('Error parsing JSON:', error) - return [] - } + parser: function ({ content, date }) { + let data + try { + data = JSON.parse(content) + } catch (error) { + console.error('Error parsing JSON:', error) + return [] + } - const programs = [] + if (!Array.isArray(data)) return [] - if (data && Array.isArray(data)) { - data.forEach(item => { - if (!item) return - const start = dayjs.utc(item.upphaf) - const stop = start.add(item.slott, 'm') + const programs = [] - programs.push({ - title: item.isltitill, - sub_title: item.undirtitill, - description: item.lysing, - actors: item.adalhlutverk, - directors: item.leikstjori, - start, - stop + data + .filter(item => item?.upphaf) + .forEach(item => { + const start = dayjs.utc(item.upphaf) + + if (start.format('YYYY-MM-DD') === date.format('YYYY-MM-DD')) { + programs.push({ + title: item.isltitill, + sub_title: item.undirtitill, + description: item.lysing, + category: item.flokkur, + season: item.seria, + episode: item.thattur, + actors: item.adalhlutverk, + directors: item.leikstjori, + start, + stop: start.add(item.slott, 'm') + }) + } }) - }) - } - return programs - }, + return programs + }, async channels() { try { const response = await axios.get('https://www.syn.is/api/epg?type=schedule') diff --git a/sites/syn.is/syn.is.test.js b/sites/syn.is/syn.is.test.js index 19751d23..a22d10f3 100644 --- a/sites/syn.is/syn.is.test.js +++ b/sites/syn.is/syn.is.test.js @@ -20,7 +20,7 @@ it('can generate valid url', () => { it('can parse response', () => { const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) - const result = parser({ content }).map(p => { + const result = parser({ content, date }).map(p => { p.start = p.start.toISOString() p.stop = p.stop.toISOString() return p @@ -41,6 +41,6 @@ it('can parse response', () => { }) it('can handle empty guide', () => { - const result = parser({ content: '[]' }) + const result = parser({ content: '[]', date }) expect(result).toMatchObject([]) })