Closed konrul-r10 closed 2 years ago
Problem solved. Use
` const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') const timezone = require('dayjs/plugin/timezone') const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(utc) dayjs.extend(timezone) dayjs.extend(customParseFormat) `
top of the config file.
Hello, first of all, thank you for your effort in the requested file. I am very thankful.
However, I am trying to use it with these codes:
`const dayjs = require('dayjs') const timezone = require('dayjs/plugin/timezone') const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(timezone) dayjs.extend(customParseFormat)
module.exports = { site: 'turksatkablo.com.tr', output: 'ide.xml', // path to output file (default: 'guide.xml') channels: 'turksatkablo.com.tr_tr.channels.xml', // path to channels.xml file (required) lang: 'tr', // default language for all programs (default: 'en') days: 3, // number of days for which to grab the program (default: 1) delay: 3000, // delay between requests (default: 3000)
url: function ({ date }) { return
https://www.turksatkablo.com.tr/userUpload/EPG/y.json?_=${date.valueOf()}
}, parser: function ({ content, channel, date }) { let PM = false let programs = [] const items = parseItems(content, channel) items.forEach(item => { let start = parseStart(item, date) if (start.hour() > 11) PM = true if (start.hour() < 12 && PM) start = start.add(1, 'd') let stop = parseStop(item, date) if (stop.hour() > 11) PM = true if (stop.hour() < 12 && PM) stop = stop.add(1, 'd')} }
function parseStart(item, date) { const time =
${date.format('MM/DD/YYYY')} ${item.c}
return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Istanbul') }
function parseStop(item, date) { const time =
${date.format('MM/DD/YYYY')} ${item.d}
return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Istanbul') }
function parseItems(content, channel) { const parsed = JSON.parse(content) const channels = parsed.k if (!channels) return [] const data = channels.find(c => c.x == channel.site_id)
return data ? data.p : [] } `
When I use
epg-grabber --config=turksatkablo.com.tr2.config.js
I get that error: `pi@rpi:~/EPG $ epg-grabber --config=turksatkablo.com.tr2.config.jsStarting... Loading 'turksatkablo.com.tr2.config.js'... Loading 'turksatkablo.com.tr_tr.channels.xml'... turksatkablo.com.tr - TR:24Kitchen - Oct 27, 2021 (0 programs) Error: o.utc is not a function`
How can I fix it? (I have installed "dayjs" with
sudo npm install dayjs
)Thanks in advance.