diff --git a/sites/nzxmltv.com/nzxmltv.com.channels.xml b/sites/nzxmltv.com/nzxmltv.com.channels.xml deleted file mode 100644 index 6dea168d..00000000 --- a/sites/nzxmltv.com/nzxmltv.com.channels.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - Al Jazeera - Bravo - Bravo Plus 1 - CH200 - eden - eden+1 - Firstlight - HGTV - Hope Channel - PRIME - PRIME +1 - Rush - Shine TV - Te Reo - Three - ThreePlus1 - TVNZ 1 - TVNZ 1 +1 - TVNZ 2 - TVNZ 2 +1 - TVNZ DUKE - TVNZ DUKE +1 - Wairarapa TV - Whakaata Māori - diff --git a/sites/nzxmltv.com/nzxmltv.com.config.js b/sites/nzxmltv.com/nzxmltv.com.config.js index bb9f7c48..4c6e42b8 100644 --- a/sites/nzxmltv.com/nzxmltv.com.config.js +++ b/sites/nzxmltv.com/nzxmltv.com.config.js @@ -7,9 +7,13 @@ module.exports = { cache: { ttl: 3600000 // 1 hour }, - maxContentLength: 10485760 // 10 MB + maxContentLength: 104857600 // 100 MB + }, + url({ channel }) { + const [path] = channel.site_id.split('#') + + return `https://nzxmltv.com/${path}.xml` }, - url: 'https://nzxmltv.com/xmltv/guide.xml', parser({ content, channel, date }) { const programs = [] parseItems(content, channel, date).forEach(item => { @@ -35,21 +39,32 @@ module.exports = { return programs }, - async channels() { + async channels({ provider }) { const axios = require('axios') const cheerio = require('cheerio') + + const providers = { + freeview: 'xmltv/guide', + sky: 'sky/guide', + redbull: 'iptv/redbull', + pluto: 'iptv/plutotv' + } + + const channels = [] + const path = providers[provider] const xml = await axios - .get('https://nzxmltv.com/xmltv/guide.xml') + .get(`https://nzxmltv.com/${path}.xml`) .then(r => r.data) .catch(console.error) - const channels = [] const $ = cheerio.load(xml) $('tv channel').each((i, el) => { const disp = $(el).find('display-name') + const channelId = $(el).attr('id') + channels.push({ lang: disp.attr('lang').substr(0, 2), - site_id: $(el).attr('id'), + site_id: `${path}#${channelId}`, name: disp.text().trim() }) }) @@ -60,6 +75,7 @@ module.exports = { function parseItems(content, channel, date) { const { programs } = parser.parse(content) + const [, channelId] = channel.site_id.split('#') - return programs.filter(p => p.channel === channel.site_id && date.isSame(p.start, 'day')) + return programs.filter(p => p.channel === channelId && date.isSame(p.start, 'day')) } diff --git a/sites/nzxmltv.com/nzxmltv.com.test.js b/sites/nzxmltv.com/nzxmltv.com.test.js index 0408cd38..f1af8d89 100644 --- a/sites/nzxmltv.com/nzxmltv.com.test.js +++ b/sites/nzxmltv.com/nzxmltv.com.test.js @@ -1,6 +1,3 @@ -// npm run channels:parse -- --config=./sites/nzxmltv.com/nzxmltv.com.config.js --output=./sites/nzxmltv.com/nzxmltv.com.channels.xml -// npm run grab -- --site=nzxmltv.com - const { parser, url } = require('./nzxmltv.com.config.js') const fs = require('fs') const path = require('path') @@ -13,12 +10,12 @@ dayjs.extend(utc) const date = dayjs.utc('2023-11-21').startOf('d') const channel = { - site_id: '1', + site_id: 'xmltv/guide#1', xmltv_id: 'TVNZ1.nz' } it('can generate valid url', () => { - expect(url).toBe('https://nzxmltv.com/xmltv/guide.xml') + expect(url({ channel })).toBe('https://nzxmltv.com/xmltv/guide.xml') }) it('can parse response', () => { diff --git a/sites/nzxmltv.com/nzxmltv.com_freeview.channels.xml b/sites/nzxmltv.com/nzxmltv.com_freeview.channels.xml new file mode 100644 index 00000000..af594c8b --- /dev/null +++ b/sites/nzxmltv.com/nzxmltv.com_freeview.channels.xml @@ -0,0 +1,38 @@ + + + + Al Jazeera + Bravo + Bravo Plus 1 + CH200 + eden + eden+1 + Firstlight + HGTV + Hope Channel + Rush + Shine TV + PRIME + PRIME +1 + Te Reo + Three + ThreePlus1 + TVNZ 1 + TVNZ 1 +1 + TVNZ 2 + TVNZ 2 +1 + TVNZ DUKE + TVNZ DUKE +1 + Wairarapa TV + Whakaata Māori + diff --git a/sites/nzxmltv.com/nzxmltv.com_pluto.channels.xml b/sites/nzxmltv.com/nzxmltv.com_pluto.channels.xml new file mode 100644 index 00000000..7a7977e7 --- /dev/null +++ b/sites/nzxmltv.com/nzxmltv.com_pluto.channels.xml @@ -0,0 +1,401 @@ + + + + diff --git a/sites/nzxmltv.com/nzxmltv.com_redbull.channels.xml b/sites/nzxmltv.com/nzxmltv.com_redbull.channels.xml new file mode 100644 index 00000000..d77d571c --- /dev/null +++ b/sites/nzxmltv.com/nzxmltv.com_redbull.channels.xml @@ -0,0 +1,4 @@ + + + Red Bull TV + diff --git a/sites/nzxmltv.com/nzxmltv.com_sky.channels.xml b/sites/nzxmltv.com/nzxmltv.com_sky.channels.xml new file mode 100644 index 00000000..5206e3e4 --- /dev/null +++ b/sites/nzxmltv.com/nzxmltv.com_sky.channels.xml @@ -0,0 +1,101 @@ + + + + Al Jazeera + Animal Planet + BBC Earth + BBC World News + BBC UKTV + Bravo + Bravo Plus 1 + Cartoon Network + CBeebies + CGTN + CGTN Documentary + CNBC + CNN + Colors + Comedy Central + Country TV + CI + Daystar + Discovery + Discovery Turbo + eden + eden+1 + ESPN + ESPN2 + Face TV + Firstlight + Fox News + HGTV + HISTORY + Hope Channel + ID + Jones + Jones! too + Living + MTV + MTV 80s + MTV Hits HD + Nickelodeon + Nick Jr + Nick Music + Parliament TV + Rialto + Rush + SonLife + Shine TV + Sky 5 + SKY Arena + SKY ARTS + SBO Movies 1 + SBO Movies 2 + SBO Movies 3 + SBO Movies 4 + SKY BOX SETS + SKY Movies Action + SKY Movies Classics + SKY Movies Collection + SKY Movies Comedy + SKY Movies Family + Sky Movies Greats + Sky Movies Premiere + Sky News + Sky Open + PRIME +1 + Sky Sport 1 + Sky Sport 2 + Sky Sport 3 + Sky Sport 4 + Sky Sport 5 + Sky Sport 6 + Sky Sport 7 + Sky Sport 9 + Sky Sport Premier League + Sky Sport Select + SoHo + Star Gold + Star Plus Hindi + Trackside 1 + Trackside 2 + Te Reo + TFC + The Shopping Channel + Three + ThreePlus1 + TLC + TVNZ 1 + TVNZ 1 +1 + TVNZ 2 + TVNZ 2 +1 + TVNZ DUKE + TVNZ DUKE +1 + Universal + Vibe + Whakaata Māori + diff --git a/sites/nzxmltv.com/readme.md b/sites/nzxmltv.com/readme.md new file mode 100644 index 00000000..25f48b41 --- /dev/null +++ b/sites/nzxmltv.com/readme.md @@ -0,0 +1,61 @@ +# nzxmltv.com + +https://nzxmltv.com/ + +### Download the guide + +Freeview: + +```sh +npm run grab -- --channels=sites/nzxmltv.com/nzxmltv.com_freeview.channels.xml +``` + +Sky: + +```sh +npm run grab -- --channels=sites/nzxmltv.com/nzxmltv.com_sky.channels.xml +``` + +Red Bull TV: + +```sh +npm run grab -- --channels=sites/nzxmltv.com/nzxmltv.com_redbull.channels.xml +``` + +Pluto TV: + +```sh +npm run grab -- --channels=sites/nzxmltv.com/nzxmltv.com_pluto.channels.xml +``` + +### Update channel list + +Freeview: + +```sh +npm run channels:parse -- --config=./sites/nzxmltv.com/nzxmltv.com.config.js --output=./sites/nzxmltv.com/nzxmltv.com_freeview.channels.xml --set=provider:freeview +``` + +Sky: + +```sh +npm run channels:parse -- --config=./sites/nzxmltv.com/nzxmltv.com.config.js --output=./sites/nzxmltv.com/nzxmltv.com_sky.channels.xml --set=provider:sky +``` + +Red Bull TV: + +```sh +npm run channels:parse -- --config=./sites/nzxmltv.com/nzxmltv.com.config.js --output=./sites/nzxmltv.com/nzxmltv.com_redbull.channels.xml --set=provider:redbull +``` + +Pluto TV: + +```sh +npm run channels:parse -- --config=./sites/nzxmltv.com/nzxmltv.com.config.js --output=./sites/nzxmltv.com/nzxmltv.com_pluto.channels.xml --set=provider:pluto +``` + +### Test + +```sh +npm test -- nzxmltv.com +```