Update tv.cctv.com

This commit is contained in:
freearhey committed 2023-11-28 19:19:56 +03:00
1 parent 4f92948e11
commit 0f48507455
4 files changed
+68

No files matched your search

+1
View File
@@ -0,0 +1 @@
{"data":{"cctv1":{"channelName":"CCTV-1 综合","lvUrl":"https://tv.cctv.com/live/cctv1","vip_flag":0,"list":[{"title":"今日说法-2023-302","startTime":1701277980,"endTime":1701279675,"showTime":"01:13","eventType":"","eventId":"","length":1695,"column_url":"https://tv.cctv.com/lm/jrsf/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/jrsf/videoset/","top":""},{"title":"人与自然-2023-248","startTime":1701279675,"endTime":1701281415,"showTime":"01:41","eventType":"","eventId":"","length":1740,"column_url":"https://tv.cctv.com/lm/ryzr/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/ryzr/index.shtml","top":""},{"title":"晚间新闻","startTime":1701281415,"endTime":1701283355,"showTime":"02:10","eventType":"","eventId":"","length":1940,"column_url":"https://tv.cctv.com/lm/wjxw/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/wjxw/index.shtml","top":""},{"title":"精彩一刻-2023-12湿地扎陵湖","startTime":1701283355,"endTime":1701283650,"showTime":"02:42","eventType":"","eventId":"","length":295,"column_url":"","columnBackvideourl":"","top":""},{"title":"精彩一刻-2023-13湿地天鹅洲","startTime":1701283650,"endTime":1701284100,"showTime":"02:47","eventType":"","eventId":"","length":450,"column_url":"","columnBackvideourl":"","top":""},{"title":"非遗里的中国-3","startTime":1701284100,"endTime":1701289740,"showTime":"02:55","eventType":"","eventId":"","length":5640,"column_url":"","columnBackvideourl":"","top":""},{"title":"今日说法-2023-302","startTime":1701289740,"endTime":1701291600,"showTime":"04:29","eventType":"","eventId":"","length":1860,"column_url":"https://tv.cctv.com/lm/jrsf/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/jrsf/videoset/","top":""},{"title":"新闻联播","startTime":1701291600,"endTime":1701293400,"showTime":"05:00","eventType":"","eventId":"","length":1800,"column_url":"https://tv.cctv.com/lm/xwlb/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/xwlb/index.shtml","top":""},{"title":"人与自然-2023-249","startTime":1701293400,"endTime":1701295200,"showTime":"05:30","eventType":"","eventId":"","length":1800,"column_url":"https://tv.cctv.com/lm/ryzr/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/ryzr/index.shtml","top":""},{"title":"朝闻天下","startTime":1701295200,"endTime":1701304595,"showTime":"06:00","eventType":"","eventId":"","length":9395,"column_url":"https://tv.cctv.com/lm/zwtx/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/zwtx/index.shtml","top":""},{"title":"生活早参考-特别节目(生活圈)2023-243","startTime":1701304595,"endTime":1701307560,"showTime":"08:36","eventType":"","eventId":"","length":2965,"column_url":"https://tv.cctv.com/lm/shq/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/shq/index.shtml","top":""},{"title":"人世间32/58","startTime":1701307560,"endTime":1701310485,"showTime":"09:26","eventType":"","eventId":"","length":2925,"column_url":"","columnBackvideourl":"","top":""},{"title":"人世间33/58","startTime":1701310485,"endTime":1701313410,"showTime":"10:14","eventType":"","eventId":"","length":2925,"column_url":"","columnBackvideourl":"","top":""},{"title":"人世间34/58","startTime":1701313410,"endTime":1701316260,"showTime":"11:03","eventType":"","eventId":"","length":2850,"column_url":"","columnBackvideourl":"","top":""},{"title":"2023秘境之眼-312","startTime":1701316260,"endTime":1701316500,"showTime":"11:51","eventType":"","eventId":"","length":240,"column_url":"","columnBackvideourl":"","top":""},{"title":"寻宝-文脉春秋宣传片(3分钟)","startTime":1701316500,"endTime":1701316800,"showTime":"11:55","eventType":"","eventId":"","length":300,"column_url":"","columnBackvideourl":"","top":""},{"title":"新闻30分","startTime":1701316800,"endTime":1701318990,"showTime":"12:00","eventType":"","eventId":"","length":2190,"column_url":"https://tv.cctv.com/lm/xw30f/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/xw30f/index.shtml","top":""},{"title":"今日说法-2023-303","startTime":1701318990,"endTime":1701321060,"showTime":"12:36","eventType":"","eventId":"","length":2070,"column_url":"https://tv.cctv.com/lm/jrsf/index.shtml","columnBackvideourl":"https://tv.cctv.com/lm/jrsf/videoset/","top":""},{"title":"梦中的那片海27/38","startTime":1701321060,"endTime":1701323940,"showTime":"13:11","eventType":"","eventId":"","length":2880,"column_url":"","columnBackvideourl":"","top":""},{"title":"梦中的那片海28/38","startTime":1701323940,"endTime":1701326920,"showTime":"13:59","eventType":"","eventId":"","length":2980,"column_url":"","columnBackvideourl":"","top":""},{"title":"梦中的那片海29/38","startTime":1701326920,"endTime":1701329775,"showTime":"14:48","eventType":"","eventId":"","length":2855,"column_url":"","columnBackvideourl":"","top":""},{"title":"梦中的那片海30/38","startTime":1701329775,"endTime":1701332755,"showTime":"15:36","eventType":"","eventId":"","length":2980,"columnLine truncated
+15
View File
@@ -0,0 +1,15 @@
# tv.cctv.com
https://tv.cctv.com/epg/index.shtml
### Download the guide
```sh
npm run grab -- --site=tv.cctv.com
```
### Test
```sh
npm test -- tv.cctv.com
```
+1
View File
@@ -36,6 +36,7 @@ function parseStart(item) {
function parseItems(content, channel) {
const data = JSON.parse(content)
if (!data || !data.data) return []
return data.data[channel.site_id].list || []
}
+51
View File
@@ -0,0 +1,51 @@
const { parser, url } = require('./tv.cctv.com.config.js')
const fs = require('fs')
const path = require('path')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
const date = dayjs.utc('2023-11-30', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: 'cctv1',
xmltv_id: 'CCTV1.cn'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://api.cntv.cn/epg/getEpgInfoByChannelNew?serviceId=tvcctv&c=cctv1&d=20231130'
)
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
const results = parser({ channel, content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(37)
expect(results[0]).toMatchObject({
start: '2023-11-29T17:13:00.000Z',
stop: '2023-11-29T17:41:15.000Z',
title: '今日说法-2023-302'
})
expect(results[36]).toMatchObject({
start: '2023-11-30T15:30:15.000Z',
stop: '2023-11-30T15:59:00.000Z',
title: '非遗里的中国-4'
})
})
it('can handle empty guide', () => {
const results = parser({
channel,
content: '{"errcode":"1001","msg":"params error"}'
})
expect(results.length).toBe(0)
})