mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Replace LF endings with CRLF
This commit is contained in:
@@ -1,45 +1,45 @@
|
||||
const axios = require('axios')
|
||||
const parser = require('epg-parser')
|
||||
|
||||
module.exports = {
|
||||
site: 'epg.112114.xyz',
|
||||
days: 1,
|
||||
url: 'https://epg.112114.xyz/pp.xml',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title?.[0]?.value,
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.get('https://epg.112114.xyz/pp.xml')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
const { channels } = parser.parse(data)
|
||||
|
||||
return channels.map(channel => ({
|
||||
lang: 'zh',
|
||||
site_id: channel.id,
|
||||
name: channel.displayName[0].value
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
const { programs } = parser.parse(content)
|
||||
|
||||
return programs.filter(p => p.channel === channel.site_id && date.isSame(p.start, 'day'))
|
||||
}
|
||||
const axios = require('axios')
|
||||
const parser = require('epg-parser')
|
||||
|
||||
module.exports = {
|
||||
site: 'epg.112114.xyz',
|
||||
days: 1,
|
||||
url: 'https://epg.112114.xyz/pp.xml',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title?.[0]?.value,
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.get('https://epg.112114.xyz/pp.xml')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
const { channels } = parser.parse(data)
|
||||
|
||||
return channels.map(channel => ({
|
||||
lang: 'zh',
|
||||
site_id: channel.id,
|
||||
name: channel.displayName[0].value
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
const { programs } = parser.parse(content)
|
||||
|
||||
return programs.filter(p => p.channel === channel.site_id && date.isSame(p.start, 'day'))
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
const { parser, url } = require('./epg.112114.xyz.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
const date = dayjs.utc('2025-01-11', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: 'BTV文艺', xmltv_id: 'BRTVArtsChannel.cn', lang: 'zh' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://epg.112114.xyz/pp.xml')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml'))
|
||||
const results = parser({ date, content, channel })
|
||||
|
||||
expect(results.length).toBe(28)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-11T00:07:00.000Z',
|
||||
stop: '2025-01-11T00:24:00.000Z',
|
||||
title: '每日文艺播报'
|
||||
})
|
||||
expect(results[27]).toMatchObject({
|
||||
start: '2025-01-11T15:16:00.000Z',
|
||||
stop: '2025-01-11T15:59:00.000Z',
|
||||
title: '笑动剧场'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: ''
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./epg.112114.xyz.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
const date = dayjs.utc('2025-01-11', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: 'BTV文艺', xmltv_id: 'BRTVArtsChannel.cn', lang: 'zh' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://epg.112114.xyz/pp.xml')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml'))
|
||||
const results = parser({ date, content, channel })
|
||||
|
||||
expect(results.length).toBe(28)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-11T00:07:00.000Z',
|
||||
stop: '2025-01-11T00:24:00.000Z',
|
||||
title: '每日文艺播报'
|
||||
})
|
||||
expect(results[27]).toMatchObject({
|
||||
start: '2025-01-11T15:16:00.000Z',
|
||||
stop: '2025-01-11T15:59:00.000Z',
|
||||
title: '笑动剧场'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: ''
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user