diff --git a/sites/rtp.pt/rtp.pt.config.js b/sites/rtp.pt/rtp.pt.config.js index 595ba419..17001b00 100644 --- a/sites/rtp.pt/rtp.pt.config.js +++ b/sites/rtp.pt/rtp.pt.config.js @@ -4,7 +4,15 @@ const timezone = require('dayjs/plugin/timezone') const customParseFormat = require('dayjs/plugin/customParseFormat') const fs = require('fs') const path = require('path') -const { EPGGrabber } = require('epg-grabber') + +let EPGGrabber + +async function getEPGGrabber() { + if (!EPGGrabber) { + EPGGrabber = (await import('epg-grabber')).EPGGrabber + } + return EPGGrabber +} dayjs.extend(utc) dayjs.extend(timezone) @@ -26,8 +34,9 @@ module.exports = { return [] } + const grabber = await getEPGGrabber() const xml = fs.readFileSync(channelsPath, 'utf8') - const parsed = EPGGrabber.parseChannelsXML(xml) + const parsed = grabber.parseChannelsXML(xml) return parsed.map(channel => ({ xmltv_id: channel.xmltv_id, diff --git a/sites/sporttv.pt/sporttv.pt.config.js b/sites/sporttv.pt/sporttv.pt.config.js index 4d182b90..7e1d7480 100644 --- a/sites/sporttv.pt/sporttv.pt.config.js +++ b/sites/sporttv.pt/sporttv.pt.config.js @@ -2,7 +2,15 @@ const dayjs = require('dayjs') const cheerio = require('cheerio') const fs = require('fs') const path = require('path') -const { EPGGrabber } = require('epg-grabber') + +let EPGGrabber + +async function getEPGGrabber() { + if (!EPGGrabber) { + EPGGrabber = (await import('epg-grabber')).EPGGrabber + } + return EPGGrabber +} module.exports = { site: 'sporttv.pt', @@ -15,7 +23,8 @@ module.exports = { } const xml = fs.readFileSync(channelsPath, 'utf8') - const parsed = EPGGrabber.parseChannelsXML(xml) + const grabber = await getEPGGrabber() + const parsed = grabber.parseChannelsXML(xml) return parsed.map(channel => ({ xmltv_id: channel.xmltv_id, diff --git a/sites/vodafone.pt/vodafone.pt.config.js b/sites/vodafone.pt/vodafone.pt.config.js index 73a5cf38..ab1ea3ca 100644 --- a/sites/vodafone.pt/vodafone.pt.config.js +++ b/sites/vodafone.pt/vodafone.pt.config.js @@ -2,7 +2,15 @@ const { DateTime } = require('luxon') const axios = require('axios') const fs = require('fs') const path = require('path') -const { EPGGrabber } = require('epg-grabber') + +let EPGGrabber + +async function getEPGGrabber() { + if (!EPGGrabber) { + EPGGrabber = (await import('epg-grabber')).EPGGrabber + } + return EPGGrabber +} const API_ENDPOINT = 'https://cdn.pt.vtv.vodafone.com/epg' @@ -25,7 +33,8 @@ module.exports = { } const xml = fs.readFileSync(channelsPath, 'utf8') - const parsed = EPGGrabber.parseChannelsXML(xml) + const grabber = await getEPGGrabber() + const parsed = grabber.parseChannelsXML(xml) return parsed.map(channel => ({ xmltv_id: channel.xmltv_id,