mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update epg.i-cable.com.config.js
This commit is contained in:
parent
f9839234d6
commit
cb5f5184f0
1 changed files with 12 additions and 18 deletions
|
@ -1,12 +1,5 @@
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const dayjs = require('dayjs')
|
const { DateTime } = require('luxon')
|
||||||
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 API_ENDPOINT = 'http://epg.i-cable.com/ci/channel'
|
const API_ENDPOINT = 'http://epg.i-cable.com/ci/channel'
|
||||||
|
|
||||||
|
@ -27,18 +20,18 @@ module.exports = {
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
const prev = programs[programs.length - 1]
|
const prev = programs[programs.length - 1]
|
||||||
let start = parseStart(item, date)
|
let start = parseStart(item, date)
|
||||||
const stop = start.add(30, 'm')
|
const stop = start.plus({ minutes: 30 })
|
||||||
if (prev) {
|
if (prev) {
|
||||||
if (start.isBefore(prev.start)) {
|
if (start < prev.start) {
|
||||||
start = start.add(1, 'd')
|
start = start.plus({ days: 1 })
|
||||||
date = date.add(1, 'd')
|
date = date.add(1, 'd')
|
||||||
}
|
}
|
||||||
prev.stop = start
|
prev.stop = start
|
||||||
}
|
}
|
||||||
programs.push({
|
programs.push({
|
||||||
title: parseTitle(item, channel),
|
title: parseTitle(item, channel),
|
||||||
start: start,
|
start,
|
||||||
stop: stop
|
stop
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +71,12 @@ function parseTitle(item, channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item, date) {
|
function parseStart(item, date) {
|
||||||
return dayjs.tz(
|
let meridiem = item.session_mark === 'PM' ? 'PM' : 'AM'
|
||||||
`${date.format('YYYY-MM-DD')} ${item.time} ${item.session_mark}`,
|
return DateTime.fromFormat(
|
||||||
'YYYY-MM-DD hh:mm A',
|
`${date.format('YYYY-MM-DD')} ${item.time} ${meridiem}`,
|
||||||
'Asia/Hong_Kong'
|
'yyyy-MM-dd hh:mm a',
|
||||||
)
|
{ zone: 'Asia/Hong_Kong' }
|
||||||
|
).toUTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, date) {
|
function parseItems(content, date) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue