diff --git a/sites/thesportplus.com/__data__/content.html b/sites/thesportplus.com/__data__/content.html new file mode 100644 index 00000000..42666219 --- /dev/null +++ b/sites/thesportplus.com/__data__/content.html @@ -0,0 +1,223 @@ + + + + + + + Sport Plus + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ Sport Plus U.S.A. +

Sport Plus U.S.A.

+ +
+
+ « + + SUN 19/01 + + » +
+ +
+
+ +
*New York time
+ +
+

01:00

+
ASTERAS vs ATROMITOS
+

Super League Season 24-25 MD 4

+
+ +
+

03:00

+
KALLITHEA vs VOLOS
+

Super League Season 24-25 MD 19

+
+ +
+

05:00

+
OLYMPIACOS vs MAROUSI
+

Greek Basket League 24-25 GD 11

+
+ +
+

07:00

+
PURE ACTION
+

Extreme Sports

+
+ +
+

08:00

+
ATROMITOS vs OLYMPIACOS LIVE
+

Super League Season 24-25 MD 19

+
+ +
+

10:00

+
LEVADIAKOS vs ASTERAS
+

Super League Season 24-25 MD 19

+
+ +
+

12:00

+
ARIS vs PAOK LIVE
+

Super League Season 24-25 MD 19

+
+ +
+

15:00

+
AEK vs PAOK
+

Greek Basket League 24-25 GD 15

+
+ +
+

14:00

+
PURE ACTION
+

Extreme Sports

+
+ +
+

17:00

+
SPORTSHOW
+

Super League

+
+ +
+

19:00

+
ATROMITOS vs OLYMPIACOS
+

Super League Season 24-25 MD 19

+
+ +
+

21:00

+
ARIS vs PAOK
+

Super League Season 24-25 MD 19

+
+ +
+

23:00

+
SPORTSHOW
+

Super League

+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/sites/thesportplus.com/__data__/no_content.html b/sites/thesportplus.com/__data__/no_content.html new file mode 100644 index 00000000..976553d2 --- /dev/null +++ b/sites/thesportplus.com/__data__/no_content.html @@ -0,0 +1,145 @@ + + + + + + + Sport Plus + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ Sport Plus U.S.A. +

Sport Plus U.S.A.

+ +
+
+ « + + MON 19/01 + + » +
+ +
+
+ +
*New York time
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/sites/thesportplus.com/readme.md b/sites/thesportplus.com/readme.md new file mode 100644 index 00000000..a70f13c5 --- /dev/null +++ b/sites/thesportplus.com/readme.md @@ -0,0 +1,17 @@ +# thesportplus.com + +US: https://www.thesportplus.com/schedule_usa.php +Australia: https://www.thesportplus.com/schedule_aus.php +Europe: https://www.thesportplus.com/schedule_euro.php + +### Download the guide + +```sh +npm run grab --- --site=thesportplus.com +``` + +### Test + +```sh +npm test --- thesportplus.com +``` diff --git a/sites/thesportplus.com/thesportplus.com.channels.xml b/sites/thesportplus.com/thesportplus.com.channels.xml new file mode 100644 index 00000000..c2d560fc --- /dev/null +++ b/sites/thesportplus.com/thesportplus.com.channels.xml @@ -0,0 +1,6 @@ + + + Sport Plus U.S.A. + Sport Plus Australia + Sport Plus Europe + \ No newline at end of file diff --git a/sites/thesportplus.com/thesportplus.com.config.js b/sites/thesportplus.com/thesportplus.com.config.js new file mode 100644 index 00000000..dd48e5e2 --- /dev/null +++ b/sites/thesportplus.com/thesportplus.com.config.js @@ -0,0 +1,73 @@ +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) + +const timezones = { + usa: 'America/New_York', + aus: 'Australia/Sydney', + euro: 'UTC' +} + +module.exports = { + site: 'thesportplus.com', + days: 2, + url({ channel, date }) { + return `https://www.thesportplus.com/schedule_${channel.site_id}.php?d=${date.format( + 'YYYY-MM-DD' + )}` + }, + parser({ content, date, channel }) { + const programs = [] + const items = parseItems(content) + items.forEach(item => { + const $item = cheerio.load(item) + const prev = programs[programs.length - 1] + let start = parseStart($item, date, channel) + if (!start) return + if (prev) { + if (start.isBefore(prev.start) && start.hour() < 12) { + start = start.add(1, 'd') + date = date.add(1, 'd') + } + prev.stop = start + } + const stop = start.add(1, 'h') + programs.push({ + title: parseTitle($item), + description: parseDescription($item), + start, + stop + }) + }) + + return programs + } +} + +function parseTitle($item) { + return $item('h5:last').text().trim() +} + +function parseDescription($item) { + return $item('p').text().trim() +} + +function parseStart($item, date, channel) { + const timezone = timezones[channel.site_id] + const time = $item('h4').text().trim() + const dateString = `${date.format('YYYY-MM-DD')} ${time}` + + return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', timezone) +} + +function parseItems(content) { + const $ = cheerio.load(content) + + return $('.resume-item').toArray() +} diff --git a/sites/thesportplus.com/thesportplus.com.test.js b/sites/thesportplus.com/thesportplus.com.test.js new file mode 100644 index 00000000..ed431fda --- /dev/null +++ b/sites/thesportplus.com/thesportplus.com.test.js @@ -0,0 +1,50 @@ +const { parser, url } = require('./thesportplus.com.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-01-19', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'usa', + xmltv_id: 'SportPlusUSA.us' +} + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe('https://www.thesportplus.com/schedule_usa.php?d=2025-01-19') +}) + +it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) + const results = parser({ content, date, channel }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(results.length).toBe(13) + expect(results[0]).toMatchObject({ + start: '2025-01-19T06:00:00.000Z', + stop: '2025-01-19T08:00:00.000Z', + title: 'ASTERAS vs ATROMITOS', + description: 'Super League Season 24-25 MD 4' + }) + expect(results[12]).toMatchObject({ + start: '2025-01-20T04:00:00.000Z', + stop: '2025-01-20T05:00:00.000Z', + title: 'SPORTSHOW', + description: 'Super League' + }) +}) + +it('can handle empty guide', () => { + const results = parser({ + date, + channel, + content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html')) + }) + expect(results).toMatchObject([]) +})