mirror of
https://github.com/iptv-org/epg
synced 2026-05-10 03:17:04 -04:00
.
This commit is contained in:
@@ -15,7 +15,7 @@ module.exports = {
|
|||||||
url({ channel, date }) {
|
url({ channel, date }) {
|
||||||
return `https://www.syn.is/api/epg/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
return `https://www.syn.is/api/epg/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||||
},
|
},
|
||||||
parser: function ({ content }) {
|
parser: function ({ content, date }) {
|
||||||
let data
|
let data
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(content)
|
data = JSON.parse(content)
|
||||||
@@ -24,25 +24,30 @@ module.exports = {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(data)) return []
|
||||||
|
|
||||||
const programs = []
|
const programs = []
|
||||||
|
|
||||||
if (data && Array.isArray(data)) {
|
data
|
||||||
data.forEach(item => {
|
.filter(item => item?.upphaf)
|
||||||
if (!item) return
|
.forEach(item => {
|
||||||
const start = dayjs.utc(item.upphaf)
|
const start = dayjs.utc(item.upphaf)
|
||||||
const stop = start.add(item.slott, 'm')
|
|
||||||
|
|
||||||
|
if (start.format('YYYY-MM-DD') === date.format('YYYY-MM-DD')) {
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.isltitill,
|
title: item.isltitill,
|
||||||
sub_title: item.undirtitill,
|
sub_title: item.undirtitill,
|
||||||
description: item.lysing,
|
description: item.lysing,
|
||||||
|
category: item.flokkur,
|
||||||
|
season: item.seria,
|
||||||
|
episode: item.thattur,
|
||||||
actors: item.adalhlutverk,
|
actors: item.adalhlutverk,
|
||||||
directors: item.leikstjori,
|
directors: item.leikstjori,
|
||||||
start,
|
start,
|
||||||
stop
|
stop: start.add(item.slott, 'm')
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ it('can generate valid url', () => {
|
|||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||||
const result = parser({ content }).map(p => {
|
const result = parser({ content, date }).map(p => {
|
||||||
p.start = p.start.toISOString()
|
p.start = p.start.toISOString()
|
||||||
p.stop = p.stop.toISOString()
|
p.stop = p.stop.toISOString()
|
||||||
return p
|
return p
|
||||||
@@ -41,6 +41,6 @@ it('can parse response', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', () => {
|
||||||
const result = parser({ content: '[]' })
|
const result = parser({ content: '[]', date })
|
||||||
expect(result).toMatchObject([])
|
expect(result).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user