mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 17:10:07 -04:00
Create tv.cctv.com.config.js
This commit is contained in:
parent
cebcbd8c40
commit
91989a4f96
1 changed files with 47 additions and 0 deletions
47
sites/tv.cctv.com.config.js
Normal file
47
sites/tv.cctv.com.config.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
lang: 'cn',
|
||||||
|
days: 3,
|
||||||
|
request: {
|
||||||
|
timeout: 10000
|
||||||
|
},
|
||||||
|
site: 'tv.cctv.com',
|
||||||
|
channels: 'tv.cctv.com.channels.xml',
|
||||||
|
output: '.gh-pages/guides/tv.cctv.com.guide.xml',
|
||||||
|
url({ channel, date }) {
|
||||||
|
return `https://api.cntv.cn/epg/getEpgInfoByChannelNew?serviceId=tvcctv&c=${
|
||||||
|
channel.site_id
|
||||||
|
}&d=${date.format('YYYYMMDD')}`
|
||||||
|
},
|
||||||
|
parser({ content, channel }) {
|
||||||
|
const programs = []
|
||||||
|
const items = parseItems(content, channel)
|
||||||
|
items.forEach(item => {
|
||||||
|
const title = item.title
|
||||||
|
const start = parseStart(item)
|
||||||
|
const stop = parseStop(item)
|
||||||
|
programs.push({
|
||||||
|
title,
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStop(item) {
|
||||||
|
return dayjs.unix(item.endTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart(item) {
|
||||||
|
return dayjs.unix(item.startTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, channel) {
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
|
||||||
|
return data.data[channel.site_id].list || []
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue