mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update config / test
This commit is contained in:
parent
f126cd812d
commit
c365d97cde
2 changed files with 18 additions and 11 deletions
|
@ -29,8 +29,9 @@ module.exports = {
|
||||||
season: parseSeason(item),
|
season: parseSeason(item),
|
||||||
episode: parseEpisode(item),
|
episode: parseEpisode(item),
|
||||||
rating: parseRating(item),
|
rating: parseRating(item),
|
||||||
start: dayjs.utc(item.start_time),
|
icon: parseIcon(item),
|
||||||
stop: dayjs.utc(item.end_time)
|
start: parseTime(item.start_time),
|
||||||
|
stop: parseTime(item.end_time)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -39,12 +40,16 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
function parseItems(content, channel) {
|
||||||
const data = JSON.parse(content)
|
try {
|
||||||
if (!data) return []
|
const data = JSON.parse(content)
|
||||||
if (!Array.isArray(data.schedule)) return []
|
if (!data) return []
|
||||||
|
if (!Array.isArray(data.schedule)) return []
|
||||||
|
|
||||||
const channelData = data.schedule.filter(i => i.channel == channel.site_id)
|
const channelData = data.schedule.find(i => i.channel == channel.site_id)
|
||||||
return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : []
|
return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : []
|
||||||
|
} catch (err) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSeason(item) {
|
function parseSeason(item) {
|
||||||
|
@ -56,7 +61,7 @@ function parseEpisode(item) {
|
||||||
function parseTime(time) {
|
function parseTime(time) {
|
||||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Australia/Sydney')
|
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Australia/Sydney')
|
||||||
}
|
}
|
||||||
function parseIcon(tem) {
|
function parseIcon(item) {
|
||||||
return item.image_file ? `https://www.abc.net.au/tv/common/images/publicity/${item.image_file}` : null
|
return item.image_file ? `https://www.abc.net.au/tv/common/images/publicity/${item.image_file}` : null
|
||||||
}
|
}
|
||||||
function parseRating(item) {
|
function parseRating(item) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ const channel = {
|
||||||
}
|
}
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url({ date })).toBe(
|
expect(url({ date })).toBe(
|
||||||
'https://epg.abctv.net.au/processed/Sydney_2022-12-22.json
|
'https://epg.abctv.net.au/processed/Sydney_2022-12-22.json'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -30,8 +30,10 @@ it('can parse response', () => {
|
||||||
title: 'Silent Witness',
|
title: 'Silent Witness',
|
||||||
sub_title: 'Lift Up Your Hearts (part Two)',
|
sub_title: 'Lift Up Your Hearts (part Two)',
|
||||||
description: `When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?`,
|
description: `When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?`,
|
||||||
category: 'Entertainment',
|
category: ['Entertainment'],
|
||||||
rating: 'M',
|
rating: {
|
||||||
|
system: 'ACB',
|
||||||
|
value: 'M'},
|
||||||
season: 22,
|
season: 22,
|
||||||
episode: 4,
|
episode: 4,
|
||||||
icon: 'https://www.abc.net.au/tv/common/images/publicity/ZW2178A004S00_460.jpg',
|
icon: 'https://www.abc.net.au/tv/common/images/publicity/ZW2178A004S00_460.jpg',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue