diff --git a/sites/entertainment.ie/__data__/content.html b/sites/entertainment.ie/__data__/content.html new file mode 100644 index 00000000..0815bae1 --- /dev/null +++ b/sites/entertainment.ie/__data__/content.html @@ -0,0 +1,4548 @@ + + + + TV Channel listings | TV Guide - RTE, BBC, TG4, TV3, UTV, Sky... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + + + + + +
+ + + +
+
+
+
+
+
+

Videos on entertainment.ie

+ Watch the most popular videos on entertainment.ie + Watch More +
+
+
+
+ + + +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ RTÉ2 +
+
+ RTÉ2 +
+ + Virgin Media: 102 / Sky: 102 / Vodafone: 102 + +
+ + + + + +
+
+
+
+ +
+
+
+
+ +
+ +
+ TV legend: (R) = Repeat showing (S) = Subtitles available + + +
+
+ + +
+
+
+ + +
+
+ + + + + + +
+ + + + + + + + + + + + + + diff --git a/sites/entertainment.ie/__data__/no-content.html b/sites/entertainment.ie/__data__/no-content.html new file mode 100644 index 00000000..f33b1f03 --- /dev/null +++ b/sites/entertainment.ie/__data__/no-content.html @@ -0,0 +1,1877 @@ + + + + TV Channel listings | TV Guide - RTE, BBC, TG4, TV3, UTV, Sky... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + + + + + +
+ + + +
+
+
+
+
+
+

Videos on entertainment.ie

+ Watch the most popular videos on entertainment.ie + Watch More +
+
+
+
+ + + +
+ +
+
+
+
+
+ +
+ +
+
+
+ TV legend: (R) = Repeat showing (S) = Subtitles available + + +
+
+ + +
+
+
+ + +
+
+ + + + + + +
+ + + + + + + + + + + + + + diff --git a/sites/entertainment.ie/entertainment.ie.channels.xml b/sites/entertainment.ie/entertainment.ie.channels.xml new file mode 100644 index 00000000..46456c8d --- /dev/null +++ b/sites/entertainment.ie/entertainment.ie.channels.xml @@ -0,0 +1,113 @@ + + + + 4Music + Alibi + Animal Planet + BBC Four + BBC Three + Boomerang + Box Nation + BT Sport 1 + BT Sport 2 + BT Sport 3 + Cartoon Network + CBBC + CBeebies + CBS Drama + CBS Reality + Challenge + Channel 4 + Channel 5 + Comedy Central Extra + Comedy Central + Dave + Discovery Channel + Discovery History + Discovery Science + Discovery Turbo + DMAX + Drama + E4 + E4 Extra + Eden + Eurosport 1 + Eurosport 2 + Free Sports + GOLD + Great! Movies + Great! TV + HorrorXtra + Investigation Discovery + ITV2 + ITV3 + ITV4 + La Liga TV + Legend + More4 + MTV + National Geographic + National Geographic Wild + Nickelodeon + Nicktoons + Pick + Premier Sports 1 + Premier Sports 2 + Really + RTÉ2 + RTÉ Jr + RTÉ One + Sky Arts + Sky Atlantic + Sky Cinema Comedy + Sky Cinema Drama + Sky Cinema Family + Sky Cinema Greats + Sky Cinema Hits + Sky Cinema Premiere + Sky Cinema Sci-Fi - Horror + Sky Cinema Thriller + Sky Comedy + Sky Crime + Sky Documentaries + Sky History + Sky History 2 + Sky Max + Sky Nature + Sky Replay + Sky Sci-Fi + Sky Showcase + Sky Sports Arena HD + Sky Sports Cricket + Sky Sports Football + Sky Sports Golf + Sky Sports Main Event + Sky Sports Mix + Sky Sports NFL + Sky Sports Premier League ROI + Sky Witness + TG4 + TLC + UTV + Virgin Media Four + Virgin Media More + Virgin Media One + Virgin Media Three + Virgin Media Two + W + Yesterday + + + + + + + + + + + + + + + diff --git a/sites/entertainment.ie/entertainment.ie.config.js b/sites/entertainment.ie/entertainment.ie.config.js new file mode 100644 index 00000000..337c7872 --- /dev/null +++ b/sites/entertainment.ie/entertainment.ie.config.js @@ -0,0 +1,95 @@ +const axios = require('axios') +const cheerio = require('cheerio') +const { DateTime } = require('luxon') + +module.exports = { + site: 'entertainment.ie', + days: 2, + url: function ({ date, channel }) { + return `https://entertainment.ie/tv/${channel.site_id}/?date=${date.format( + 'DD-MM-YYYY' + )}&time=all-day` + }, + parser: function ({ content, date }) { + let programs = [] + const items = parseItems(content) + items.forEach(item => { + const prev = programs[programs.length - 1] + const $item = cheerio.load(item) + let start = parseStart($item, date) + if (!start) return + if (prev && start < prev.start) { + start = start.plus({ days: 1 }) + } + const duration = parseDuration($item) + const stop = start.plus({ minutes: duration }) + programs.push({ + title: parseTitle($item), + description: parseDescription($item), + categories: parseCategories($item), + icon: parseIcon($item), + start, + stop + }) + }) + + return programs + }, + async channels() { + const data = await axios + .get(`https://entertainment.ie/tv/all-channels/`) + .then(r => r.data) + .catch(console.log) + const $ = cheerio.load(data) + let channels = $('.tv-filter-container > tv-filter').attr(':channels') + channels = JSON.parse(channels) + + return channels.map(c => { + return { + site_id: c.slug, + name: c.name + } + }) + } +} + +function parseIcon($item) { + return $item('.text-holder > .btn-hold > .btn-wrap > a.btn-share').data('img') +} + +function parseTitle($item) { + return $item('.text-holder h3').text().trim() +} + +function parseDescription($item) { + return $item('.text-holder > .btn-hold > .btn-wrap > a.btn-share').data('description') +} + +function parseCategories($item) { + const genres = $item('.text-holder > .btn-hold > .btn-wrap > a.btn-share').data('genres') + + return genres ? genres.split(', ') : [] +} + +function parseStart($item, date) { + let d = $item('.text-holder > .btn-hold > .btn-wrap > a.btn-share').data('time') + let [_, time] = d ? d.split(', ') : [null, null] + + return time + ? DateTime.fromFormat(`${date.format('YYYY-MM-DD')} ${time}`, 'yyyy-MM-dd HH:mm', { + zone: 'UTC' + }).toUTC() + : null +} + +function parseDuration($item) { + const duration = $item('.text-holder > .btn-hold > .btn-wrap > a.btn-share').data('duration') + + return parseInt(duration) +} + +function parseItems(content) { + const $ = cheerio.load(content) + + return $(`.info-list > li`).toArray() +} diff --git a/sites/entertainment.ie/entertainment.ie.test.js b/sites/entertainment.ie/entertainment.ie.test.js new file mode 100644 index 00000000..c88911a1 --- /dev/null +++ b/sites/entertainment.ie/entertainment.ie.test.js @@ -0,0 +1,59 @@ +// npm run channels:parse -- --config=./sites/entertainment.ie/entertainment.ie.config.js --output=./sites/entertainment.ie/entertainment.ie.channels.xml +// npx epg-grabber --config=sites/entertainment.ie/entertainment.ie.config.js --channels=sites/entertainment.ie/entertainment.ie.channels.xml --output=guide.xml + +const fs = require('fs') +const path = require('path') +const { parser, url } = require('./entertainment.ie.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const customParseFormat = require('dayjs/plugin/customParseFormat') +dayjs.extend(customParseFormat) +dayjs.extend(utc) + +const date = dayjs.utc('2023-06-29', 'YYYY-MM-DD').startOf('d') +const channel = { site_id: 'rte2', xmltv_id: 'RTE2.ie' } + +it('can generate valid url', () => { + expect(url({ date, channel })).toBe( + 'https://entertainment.ie/tv/rte2/?date=29-06-2023&time=all-day' + ) +}) + +it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) + const results = parser({ date, content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(results.length).toBe(51) + + expect(results[0]).toMatchObject({ + start: '2023-06-29T06:00:00.000Z', + stop: '2023-06-29T08:00:00.000Z', + title: 'EuroNews', + description: 'European and international headlines live via satellite', + icon: 'https://img.resized.co/entertainment/eyJkYXRhIjoie1widXJsXCI6XCJodHRwczpcXFwvXFxcL3R2LmFzc2V0cy5wcmVzc2Fzc29jaWF0aW9uLmlvXFxcLzcxZDdkYWY2LWQxMjItNTliYy1iMGRjLTFkMjc2ODg1MzhkNC5qcGdcIixcIndpZHRoXCI6NDgwLFwiaGVpZ2h0XCI6Mjg4LFwiZGVmYXVsdFwiOlwiaHR0cHM6XFxcL1xcXC9lbnRlcnRhaW5tZW50LmllXFxcL2ltYWdlc1xcXC9uby1pbWFnZS5wbmdcIn0iLCJoYXNoIjoiZDhjYzA0NzFhMGZhOTI1Yjc5ODI0M2E3OWZjMGI2ZGJmMDIxMjllNyJ9/71d7daf6-d122-59bc-b0dc-1d27688538d4.jpg', + categories: ['Factual'] + }) + + expect(results[50]).toMatchObject({ + start: '2023-06-30T02:25:00.000Z', + stop: '2023-06-30T06:00:00.000Z', + title: 'EuroNews', + description: 'European and international headlines live via satellite', + icon: 'https://img.resized.co/entertainment/eyJkYXRhIjoie1widXJsXCI6XCJodHRwczpcXFwvXFxcL3R2LmFzc2V0cy5wcmVzc2Fzc29jaWF0aW9uLmlvXFxcLzcxZDdkYWY2LWQxMjItNTliYy1iMGRjLTFkMjc2ODg1MzhkNC5qcGdcIixcIndpZHRoXCI6NDgwLFwiaGVpZ2h0XCI6Mjg4LFwiZGVmYXVsdFwiOlwiaHR0cHM6XFxcL1xcXC9lbnRlcnRhaW5tZW50LmllXFxcL2ltYWdlc1xcXC9uby1pbWFnZS5wbmdcIn0iLCJoYXNoIjoiZDhjYzA0NzFhMGZhOTI1Yjc5ODI0M2E3OWZjMGI2ZGJmMDIxMjllNyJ9/71d7daf6-d122-59bc-b0dc-1d27688538d4.jpg', + categories: ['Factual'] + }) +}) + +it('can handle empty guide', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/no-content.html')) + const result = parser({ + date, + channel, + content + }) + expect(result).toMatchObject([]) +})