fix error in adding the epg-grabber module

This commit is contained in:
thomraider12
2026-03-22 10:43:32 +00:00
parent 8dfdf9ab9e
commit 23d44dcb14
3 changed files with 33 additions and 6 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,