diff --git a/sites/abc.net.au/abc.net.au.config.js b/sites/abc.net.au/abc.net.au.config.js index d353aecf..21a98795 100644 --- a/sites/abc.net.au/abc.net.au.config.js +++ b/sites/abc.net.au/abc.net.au.config.js @@ -29,8 +29,9 @@ module.exports = { season: parseSeason(item), episode: parseEpisode(item), rating: parseRating(item), - start: dayjs.utc(item.start_time), - stop: dayjs.utc(item.end_time) + icon: parseIcon(item), + start: parseTime(item.start_time), + stop: parseTime(item.end_time) }) }) @@ -39,12 +40,16 @@ module.exports = { } function parseItems(content, channel) { - const data = JSON.parse(content) - if (!data) return [] - if (!Array.isArray(data.schedule)) return [] + try { + const data = JSON.parse(content) + if (!data) return [] + if (!Array.isArray(data.schedule)) return [] - const channelData = data.schedule.filter(i => i.channel == channel.site_id) - return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : [] + const channelData = data.schedule.find(i => i.channel == channel.site_id) + return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : [] + } catch (err) { + return [] + } } function parseSeason(item) { @@ -56,7 +61,7 @@ function parseEpisode(item) { function parseTime(time) { 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 } function parseRating(item) { diff --git a/sites/abc.net.au/abc.net.au.test.js b/sites/abc.net.au/abc.net.au.test.js index 80609caf..ce9b7164 100644 --- a/sites/abc.net.au/abc.net.au.test.js +++ b/sites/abc.net.au/abc.net.au.test.js @@ -12,7 +12,7 @@ const channel = { } it('can generate valid url', () => { 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', 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?`, - category: 'Entertainment', - rating: 'M', + category: ['Entertainment'], + rating: { + system: 'ACB', + value: 'M'}, season: 22, episode: 4, icon: 'https://www.abc.net.au/tv/common/images/publicity/ZW2178A004S00_460.jpg',