mirror of
https://github.com/iptv-org/epg
synced 2026-03-26 22:00:55 -04:00
fix error in adding the epg-grabber module
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user