Merge pull request #2079 from iptv-org/fix-epg.i-cable.com

Fix epg.i-cable.com
This commit is contained in:
PopeyeTheSai10r 2023-06-08 00:16:34 -07:00 committed by GitHub
commit bb091422c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 19 deletions

View file

@ -1,12 +1,5 @@
const axios = require('axios')
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)
const { DateTime } = require('luxon')
const API_ENDPOINT = 'http://epg.i-cable.com/ci/channel'
@ -27,18 +20,18 @@ module.exports = {
for (let item of items) {
const prev = programs[programs.length - 1]
let start = parseStart(item, date)
const stop = start.add(30, 'm')
const stop = start.plus({ minutes: 30 })
if (prev) {
if (start.isBefore(prev.start)) {
start = start.add(1, 'd')
if (start < prev.start) {
start = start.plus({ days: 1 })
date = date.add(1, 'd')
}
prev.stop = start
}
programs.push({
title: parseTitle(item, channel),
start: start,
stop: stop
start,
stop
})
}
@ -78,11 +71,12 @@ function parseTitle(item, channel) {
}
function parseStart(item, date) {
return dayjs.tz(
`${date.format('YYYY-MM-DD')} ${item.time} ${item.session_mark}`,
'YYYY-MM-DD hh:mm A',
'Asia/Hong_Kong'
)
let meridiem = item.session_mark === 'PM' ? 'PM' : 'AM'
return DateTime.fromFormat(
`${date.format('YYYY-MM-DD')} ${item.time} ${meridiem}`,
'yyyy-MM-dd hh:mm a',
{ zone: 'Asia/Hong_Kong' }
).toUTC()
}
function parseItems(content, date) {

View file

@ -1,5 +1,5 @@
// npm run channels:parse -- --config=./sites/epg.i-cable.com/epg.i-cable.com.config.js --output=./sites/epg.i-cable.com/epg.i-cable.com.channels.xml --set=lang:zh
// npx epg-grabber --config=sites/epg.i-cable.com/epg.i-cable.com.config.js --channels=sites/epg.i-cable.com/epg.i-cable.com.channels.xml --output=guide.xml --days=2
// npx epg-grabber --config=sites/epg.i-cable.com/epg.i-cable.com.config.js --channels=sites/epg.i-cable.com/epg.i-cable.com.channels.xml --output=guide.xml
const { parser, url } = require('./epg.i-cable.com.config.js')
const fs = require('fs')