mirror of
https://github.com/iptv-org/epg
synced 2026-04-30 22:46:58 -04:00
Replace LF line endings with CRLF
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
# taiwanplus.com
|
||||
|
||||
https://www.taiwanplus.com/taiwanplustv/schedule
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=taiwanplus.com
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- taiwanplus.com
|
||||
```
|
||||
# taiwanplus.com
|
||||
|
||||
https://www.taiwanplus.com/taiwanplustv/schedule
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=taiwanplus.com
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- taiwanplus.com
|
||||
```
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="taiwanplus.com" lang="en" xmltv_id="TaiwanPlusTV.tw" site_id="#">TaiwanPlus TV</channel>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="taiwanplus.com" lang="en" xmltv_id="TaiwanPlusTV.tw" site_id="#">TaiwanPlus TV</channel>
|
||||
</channels>
|
||||
@@ -1,68 +1,68 @@
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const isSameOrAfter = require('dayjs/plugin/isSameOrAfter')
|
||||
const isSameOrBefore = require('dayjs/plugin/isSameOrBefore')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(isSameOrAfter)
|
||||
dayjs.extend(isSameOrBefore)
|
||||
|
||||
module.exports = {
|
||||
site: 'taiwanplus.com',
|
||||
days: 7,
|
||||
output: 'taiwanplus.com.guide.xml',
|
||||
channels: 'taiwanplus.com.channels.xml',
|
||||
lang: 'en',
|
||||
|
||||
url: function () {
|
||||
return 'https://www.taiwanplus.com/api/video/live/schedule/0'
|
||||
},
|
||||
|
||||
request: {
|
||||
method: 'GET',
|
||||
timeout: 5000,
|
||||
cache: { ttl: 60 * 60 * 1000 } // 60 * 60 seconds = 1 hour
|
||||
},
|
||||
|
||||
logo: function (context) {
|
||||
return context.channel.logo
|
||||
},
|
||||
|
||||
parser: function (context) {
|
||||
const programs = []
|
||||
const scheduleDates = parseItems(context.content)
|
||||
const today = dayjs.utc(context.date).startOf('day')
|
||||
|
||||
for (let scheduleDate of scheduleDates) {
|
||||
const currentScheduleDate = new dayjs.utc(scheduleDate.date, 'YYYY/MM/DD')
|
||||
|
||||
if (currentScheduleDate.isSame(today)) {
|
||||
scheduleDate.schedule.forEach(function (program, i) {
|
||||
programs.push({
|
||||
title: program.title,
|
||||
start: dayjs.utc(program.dateTime, 'YYYY/MM/DD HH:mm'),
|
||||
stop:
|
||||
i != scheduleDate.schedule.length - 1
|
||||
? dayjs.utc(scheduleDate.schedule[i + 1].dateTime, 'YYYY/MM/DD HH:mm')
|
||||
: dayjs.utc(program.dateTime, 'YYYY/MM/DD HH:mm').add(1, 'day').startOf('day'),
|
||||
description: program.description,
|
||||
image: program.image,
|
||||
category: program.categoryName,
|
||||
rating: program.ageRating
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
if (content != '') {
|
||||
const data = JSON.parse(content)
|
||||
return !data || !data.data || !Array.isArray(data.data) ? [] : data.data
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const isSameOrAfter = require('dayjs/plugin/isSameOrAfter')
|
||||
const isSameOrBefore = require('dayjs/plugin/isSameOrBefore')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(isSameOrAfter)
|
||||
dayjs.extend(isSameOrBefore)
|
||||
|
||||
module.exports = {
|
||||
site: 'taiwanplus.com',
|
||||
days: 7,
|
||||
output: 'taiwanplus.com.guide.xml',
|
||||
channels: 'taiwanplus.com.channels.xml',
|
||||
lang: 'en',
|
||||
|
||||
url: function () {
|
||||
return 'https://www.taiwanplus.com/api/video/live/schedule/0'
|
||||
},
|
||||
|
||||
request: {
|
||||
method: 'GET',
|
||||
timeout: 5000,
|
||||
cache: { ttl: 60 * 60 * 1000 } // 60 * 60 seconds = 1 hour
|
||||
},
|
||||
|
||||
logo: function (context) {
|
||||
return context.channel.logo
|
||||
},
|
||||
|
||||
parser: function (context) {
|
||||
const programs = []
|
||||
const scheduleDates = parseItems(context.content)
|
||||
const today = dayjs.utc(context.date).startOf('day')
|
||||
|
||||
for (let scheduleDate of scheduleDates) {
|
||||
const currentScheduleDate = new dayjs.utc(scheduleDate.date, 'YYYY/MM/DD')
|
||||
|
||||
if (currentScheduleDate.isSame(today)) {
|
||||
scheduleDate.schedule.forEach(function (program, i) {
|
||||
programs.push({
|
||||
title: program.title,
|
||||
start: dayjs.utc(program.dateTime, 'YYYY/MM/DD HH:mm'),
|
||||
stop:
|
||||
i != scheduleDate.schedule.length - 1
|
||||
? dayjs.utc(scheduleDate.schedule[i + 1].dateTime, 'YYYY/MM/DD HH:mm')
|
||||
: dayjs.utc(program.dateTime, 'YYYY/MM/DD HH:mm').add(1, 'day').startOf('day'),
|
||||
description: program.description,
|
||||
image: program.image,
|
||||
category: program.categoryName,
|
||||
rating: program.ageRating
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
if (content != '') {
|
||||
const data = JSON.parse(content)
|
||||
return !data || !data.data || !Array.isArray(data.data) ? [] : data.data
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
const { url, parser } = require('./taiwanplus.com.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2023-08-20', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '#',
|
||||
xmltv_id: 'TaiwanPlusTV.tw',
|
||||
lang: 'en',
|
||||
logo: 'https://i.imgur.com/SfcZyqm.png'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe('https://www.taiwanplus.com/api/video/live/schedule/0')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
|
||||
const results = parser({ content, date })
|
||||
|
||||
expect(results).toMatchObject([
|
||||
{
|
||||
title: 'Master Class',
|
||||
start: dayjs.utc('2023/08/20 00:00', 'YYYY/MM/DD HH:mm'),
|
||||
stop: dayjs.utc('2023/08/21 00:00', 'YYYY/MM/DD HH:mm'),
|
||||
description:
|
||||
'From blockchain to Buddha statues, Taiwan’s culture is a kaleidoscope of old and new just waiting to be discovered.',
|
||||
image: 'https://prod-img.taiwanplus.com/live-schedule/Single/S30668_20230810104937.webp',
|
||||
category: 'TaiwanPlus ✕ Discovery',
|
||||
rating: '0+'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
const { url, parser } = require('./taiwanplus.com.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2023-08-20', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '#',
|
||||
xmltv_id: 'TaiwanPlusTV.tw',
|
||||
lang: 'en',
|
||||
logo: 'https://i.imgur.com/SfcZyqm.png'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe('https://www.taiwanplus.com/api/video/live/schedule/0')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
|
||||
const results = parser({ content, date })
|
||||
|
||||
expect(results).toMatchObject([
|
||||
{
|
||||
title: 'Master Class',
|
||||
start: dayjs.utc('2023/08/20 00:00', 'YYYY/MM/DD HH:mm'),
|
||||
stop: dayjs.utc('2023/08/21 00:00', 'YYYY/MM/DD HH:mm'),
|
||||
description:
|
||||
'From blockchain to Buddha statues, Taiwan’s culture is a kaleidoscope of old and new just waiting to be discovered.',
|
||||
image: 'https://prod-img.taiwanplus.com/live-schedule/Single/S30668_20230810104937.webp',
|
||||
category: 'TaiwanPlus ✕ Discovery',
|
||||
rating: '0+'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user