Update config / test

This commit is contained in:
RevGear 2022-12-22 17:34:12 +00:00
parent f126cd812d
commit c365d97cde
2 changed files with 18 additions and 11 deletions

View file

@ -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) {
try {
const data = JSON.parse(content) const data = JSON.parse(content)
if (!data) return [] if (!data) return []
if (!Array.isArray(data.schedule)) 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) {

View file

@ -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',