From d75ce33915caed56e5ec1edf839ca978ddeb2f87 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:40:48 +0300 Subject: [PATCH 1/5] Create __data__ --- sites/dtv8.net/__data__/content_fri.html | 955 +++++++++++++++++++++++ sites/dtv8.net/__data__/content_sat.html | 944 ++++++++++++++++++++++ 2 files changed, 1899 insertions(+) create mode 100644 sites/dtv8.net/__data__/content_fri.html create mode 100644 sites/dtv8.net/__data__/content_sat.html diff --git a/sites/dtv8.net/__data__/content_fri.html b/sites/dtv8.net/__data__/content_fri.html new file mode 100644 index 00000000..c2e2b877 --- /dev/null +++ b/sites/dtv8.net/__data__/content_fri.html @@ -0,0 +1,955 @@ + + + + + + + + + + Friday, February 21 | DTV-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ +
+
+ + +
+

Friday, February 21

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TimeProgramme Name and Description
08:55 hrs.Sign On; Morning News
10:00 hrs.Live with Kelly and Mark
11:00 hrs.The Good Stuff with Mary Berg
12:00 hrs.The View
13:00 hrs.News
13:30 hrs.The Young and the Restless
14:30 hrs.The Bold and the Beautiful
15:00 hrs.The Price is Right
16:00 hrs.Let’s Make a Deal
17:00 hrs.Smallville
+A young Clark Kent struggles to find his place in the world as he learns to harness his alien powers for good and deals with the typical troubles of teenage life in Smallville, Kansas.
18:00 hrs.World News
19:00 hrs.Greetings and Announcements
20:00 hrs.Channel 8 News
20:30 hrs.Jeopardy
21:00 hrs.Matlock
21:45 hrs.Law & Order

+

In God We Trust: A young lawyer with a secret past is found dead; Price and Baxter debate the pros and cons of prison as a punishment versus alternative justice options.

22:30 hrs.Law & Order: SVU

+

Extinguished: Velasco teams up with a community security guard eager to prove his mettle to find a suspect in the assault of two teens.

23:15 hrs.Sign Off
+

Subject to Change                                                                                           Next»

+
+
+ +
+
+ +
+ +
+

Berbice Super Station

+ + + +
+ +
+ + +
+ + +
+ + + +
+ + + + + + + + diff --git a/sites/dtv8.net/__data__/content_sat.html b/sites/dtv8.net/__data__/content_sat.html new file mode 100644 index 00000000..8e4b2864 --- /dev/null +++ b/sites/dtv8.net/__data__/content_sat.html @@ -0,0 +1,944 @@ + + + + + + + + + + Saturday, February 15 | DTV-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ +
+
+ + +
+

Saturday, February 15

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TimeProgramme Name and Description
09:55 hrs.Sign On
10:00 hrs.Foster’s Home for Imaginary Friends
10:30 hrs.Xiaolin Showdown
12:00 hrs.Movie: Beauty and the Beast
15:10 hrs.Movie: 27 Dresses
18:00 hrs.World News
18:30 hrs.Nightly News
19:00 hrs.Greeting and Announcements
20:00 hrs.Alliance on the Move (Paid Programme)
21:10 hrs.Hindi Movie
00:00 hrs.Sign Off
+

Subject to Change                                                                                               Next»

+
+
+ +
+
+ +
+ +
+

Berbice Super Station

+ + + +
+ +
+ + +
+ + +
+ + + +
+ + + + + + + + From d877f4405b9706dac17d03e8a93d56cfd57662ee Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:41:30 +0300 Subject: [PATCH 2/5] Create dtv8.net.test.js --- sites/dtv8.net/dtv8.net.test.js | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 sites/dtv8.net/dtv8.net.test.js diff --git a/sites/dtv8.net/dtv8.net.test.js b/sites/dtv8.net/dtv8.net.test.js new file mode 100644 index 00000000..027519ad --- /dev/null +++ b/sites/dtv8.net/dtv8.net.test.js @@ -0,0 +1,79 @@ +const { parser, url } = require('./dtv8.net.config.js') +const fs = require('fs') +const path = require('path') +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('2025-02-21', 'YYYY-MM-DD').startOf('d') + +it('can generate valid url', () => { + expect(url({ date })).toBe('https://dtv8.net/tv-listings/friday/') +}) + +it('can parse response for friday', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content_fri.html')) + + let results = parser({ content, date }) + results = results.map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + + return p + }) + + expect(results.length).toBe(18) + expect(results[9]).toMatchObject({ + title: 'Smallville', + image: 'http://dtv8.net/wp-content/uploads/71P0aShCBXL._SL1300_.jpg', + description: + 'A young Clark Kent struggles to find his place in the world as he learns to harness his alien powers for good and deals with the typical troubles of teenage life in Smallville, Kansas.', + start: '2025-02-21T21:00:00.000Z', + stop: '2025-02-21T22:00:00.000Z' + }) + expect(results[15]).toMatchObject({ + title: 'Law & Order', + image: null, + description: + 'In God We Trust: A young lawyer with a secret past is found dead; Price and Baxter debate the pros and cons of prison as a punishment versus alternative justice options.', + start: '2025-02-22T01:45:00.000Z', + stop: '2025-02-22T02:30:00.000Z' + }) +}) + +it('can parse response for saturday', () => { + const date = dayjs.utc('2025-02-22', 'YYYY-MM-DD').startOf('d') + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content_sat.html')) + + let results = parser({ content, date }) + results = results.map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + + return p + }) + + expect(results.length).toBe(11) + expect(results[0]).toMatchObject({ + title: 'Sign On', + image: null, + description: null, + start: '2025-02-22T13:55:00.000Z', + stop: '2025-02-22T14:00:00.000Z' + }) + expect(results[10]).toMatchObject({ + title: 'Sign Off', + image: null, + description: null, + start: '2025-02-23T04:00:00.000Z', + stop: '2025-02-23T04:30:00.000Z' + }) +}) + +it('can handle empty guide', () => { + const results = parser({ content: '' }) + + expect(results).toMatchObject([]) +}) From 3100db92266a4c26e157869e282718528babc295 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:41:42 +0300 Subject: [PATCH 3/5] Create dtv8.net.config.js --- sites/dtv8.net/dtv8.net.config.js | 90 +++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 sites/dtv8.net/dtv8.net.config.js diff --git a/sites/dtv8.net/dtv8.net.config.js b/sites/dtv8.net/dtv8.net.config.js new file mode 100644 index 00000000..4d68b20f --- /dev/null +++ b/sites/dtv8.net/dtv8.net.config.js @@ -0,0 +1,90 @@ +const cheerio = require('cheerio') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const timezone = require('dayjs/plugin/timezone') +const customParseFormat = require('dayjs/plugin/customParseFormat') + +dayjs.extend(utc) +dayjs.extend(timezone) +dayjs.extend(customParseFormat) + +module.exports = { + site: 'dtv8.net', + days: 2, + url({ date }) { + const day = date.format('dddd') + + return `https://dtv8.net/tv-listings/${day.toLowerCase()}/` + }, + parser({ content, date }) { + let programs = [] + + const items = parseItems(content) + items.forEach(item => { + const $item = cheerio.load(item) + let prev = programs[programs.length - 1] + let start = parseStart($item, date) + if (prev) { + if (start < prev.start) { + start = start.add(1, 'd') + date = date.add(1, 'd') + } + prev.stop = start + } + const stop = start.add(30, 'm') + + programs.push({ + title: parseTitle($item), + description: parseDescription($item), + image: parseImage($item), + start, + stop + }) + }) + + return programs + }, + channels() { + return [] + } +} + +function parseTitle($item) { + return $item( + 'td:nth-child(2) > strong:nth-child(1),td:nth-child(2) > span > strong,td:nth-child(2) > span > b' + ).text() +} + +function parseDescription($item) { + return ( + $item( + 'td:nth-child(2) > strong:nth-child(3) > span,td:nth-child(2) > p:nth-child(3) > strong > span' + ).text() || null + ) +} + +function parseImage($item) { + return $item('td:nth-child(1) > img.size-full').attr('src') || null +} + +function parseStart($item, date) { + const time = $item('td:nth-child(1)').text() + + return dayjs.tz( + `${date.format('YYYY-MM-DD')} ${time}`, + 'YYYY-MM-DD HH:mm [hrs.]', + 'America/Guyana' + ) +} + +function parseItems(content) { + const $ = cheerio.load(content) + + return $('table tr') + .filter((i, el) => { + const firstColumn = $(el).find('td').text() + + return Boolean(firstColumn) && !firstColumn.includes('Time') + }) + .toArray() +} From ba9fd0f09951bbf5be2dd85b506181b8647fa148 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:41:50 +0300 Subject: [PATCH 4/5] Create dtv8.net.channels.xml --- sites/dtv8.net/dtv8.net.channels.xml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 sites/dtv8.net/dtv8.net.channels.xml diff --git a/sites/dtv8.net/dtv8.net.channels.xml b/sites/dtv8.net/dtv8.net.channels.xml new file mode 100644 index 00000000..ccc5cbc9 --- /dev/null +++ b/sites/dtv8.net/dtv8.net.channels.xml @@ -0,0 +1,4 @@ + + + DTV-8 + \ No newline at end of file From 9345e395338084d61f42c1885e63fff294dcf392 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:41:59 +0300 Subject: [PATCH 5/5] Create readme.md --- sites/dtv8.net/readme.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sites/dtv8.net/readme.md diff --git a/sites/dtv8.net/readme.md b/sites/dtv8.net/readme.md new file mode 100644 index 00000000..5de8f965 --- /dev/null +++ b/sites/dtv8.net/readme.md @@ -0,0 +1,15 @@ +# dtv8.net + +https://dtv8.net/tv-listings/ + +### Download the guide + +```sh +npm run grab --- --site=dtv8.net +``` + +### Test + +```sh +npm test --- dtv8.net +```