diff --git a/sites/abc.net.au/abc.net.au.channels.xml b/sites/abc.net.au/abc.net.au.channels.xml index 230ce842..c18761eb 100644 --- a/sites/abc.net.au/abc.net.au.channels.xml +++ b/sites/abc.net.au/abc.net.au.channels.xml @@ -1,35 +1,543 @@ - 10 Bold - 10 Peach - 10 Shake - 7flix - 7mate - 7two - 9 Gem - 9 Go! - 9 Life - 9 Rush - ABC News - ABC Kids - ABC ME - ABC TV Plus - ABC TV - ABC TV HD - Channel 10 - Channel 10 HD - Channel 7 - Channel 7 HD - Channel 9 - Channel 9 HD - NITV - Racing.com - SBS Food - SBS One - SBS HD - SBS Viceland - SBS World Movies - SBS World Watch - Spree TV - TSVN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ONE + 11 + SHAKE + 7bravo + 7bravo + 7flix + 7flix + 7HD + 7MATE + 7MATE + 7TWO + 7TWO + GEM + GO + 9HD + 9Life + 9Life + 9Rush + 9Rush + ABCN + ABC4KIDS + ABC3 + ABC2 + ABC1 + ABCHD + 10 + 10 + TENHD + 44 + 7 + 7 + 7HD + 9 + 9 + 9HD + NITV + NITV + RTV + SBS + SBS3 + SBS + SBSHD + VICHD + SBS2 + SBSWW + SPREE + TVSN diff --git a/sites/abc.net.au/abc.net.au.config.js b/sites/abc.net.au/abc.net.au.config.js index 26388f47..0a3eec0d 100644 --- a/sites/abc.net.au/abc.net.au.config.js +++ b/sites/abc.net.au/abc.net.au.config.js @@ -1,3 +1,4 @@ +const axios = require('axios') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') const timezone = require('dayjs/plugin/timezone') @@ -15,8 +16,10 @@ module.exports = { ttl: 60 * 60 * 1000 // 1 hour } }, - url({ date }) { - return `https://epg.abctv.net.au/processed/Sydney_${date.format('YYYY-MM-DD')}.json` + url({ date, channel }) { + const [region] = channel.site_id.split('#') + + return `https://epg.abctv.net.au/processed/${region}_${date.format('YYYY-MM-DD')}.json` }, parser({ content, channel }) { let programs = [] @@ -37,6 +40,46 @@ module.exports = { }) return programs + }, + async channels() { + const now = dayjs() + const regions = [ + 'Sydney', + 'Melbourne', + 'Brisbane', + 'GoldCoast', + 'Perth', + 'Adelaide', + 'Hobart', + 'Darwin', + 'Canberra', + 'New South Wales', + 'Victoria', + 'Townsville', + 'Queensland', + 'Western Australia', + 'South Australia', + 'Tasmania', + 'Northern Territory' + ] + + let channels = [] + for (let region of regions) { + const data = await axios + .get(`https://epg.abctv.net.au/processed/${region}_${now.format('YYYY-MM-DD')}.json`) + .then(r => r.data) + .catch(console.log) + + for (let item of data.schedule) { + channels.push({ + lang: 'en', + site_id: `${region}#${item.channel}`, + name: item.channel + }) + } + } + + return channels } } @@ -46,7 +89,8 @@ function parseItems(content, channel) { if (!data) return [] if (!Array.isArray(data.schedule)) return [] - const channelData = data.schedule.find(i => i.channel == channel.site_id) + const [, channelId] = channel.site_id.split('#') + const channelData = data.schedule.find(i => i.channel == channelId) return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : [] } catch (err) { return [] diff --git a/sites/abc.net.au/abc.net.au.test.js b/sites/abc.net.au/abc.net.au.test.js index 791302a7..e7a23093 100644 --- a/sites/abc.net.au/abc.net.au.test.js +++ b/sites/abc.net.au/abc.net.au.test.js @@ -1,3 +1,4 @@ +// npm run channels:parse -- --config=./sites/abc.net.au/abc.net.au.config.js --output=./sites/abc.net.au/abc.net.au.channels.xml // npm run grab -- --site=abc.net.au const { parser, url } = require('./abc.net.au.config.js') @@ -7,11 +8,11 @@ dayjs.extend(utc) const date = dayjs.utc('2022-12-22', 'YYYY-MM-DD').startOf('d') const channel = { - site_id: 'ABC1', + site_id: 'Sydney#ABC1', xmltv_id: 'ABCTV.au' } it('can generate valid url', () => { - expect(url({ date })).toBe('https://epg.abctv.net.au/processed/Sydney_2022-12-22.json') + expect(url({ date, channel })).toBe('https://epg.abctv.net.au/processed/Sydney_2022-12-22.json') }) it('can parse response', () => {