mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
feat: nhl.com
site
I was having trouble with the extant sites for this channel so I decided to add a source for the league's own guide. Unfortunately it's missing images since I don't know where they need to be hosted :(
This commit is contained in:
parent
7610f7b9f5
commit
5d33db08b8
6 changed files with 116 additions and 0 deletions
1
SITES.md
1
SITES.md
|
@ -91,6 +91,7 @@
|
||||||
| [mytvsuper.com](sites/mytvsuper.com) | 🟢 | |
|
| [mytvsuper.com](sites/mytvsuper.com) | 🟢 | |
|
||||||
| [nhk.or.jp](sites/nhk.or.jp) | 🟢 | |
|
| [nhk.or.jp](sites/nhk.or.jp) | 🟢 | |
|
||||||
| [nhkworldpremium.com](sites/nhkworldpremium.com) | 🟢 | |
|
| [nhkworldpremium.com](sites/nhkworldpremium.com) | 🟢 | |
|
||||||
|
| [nhl.com](sites/nhl.com) | 🟢 | |
|
||||||
| [nostv.pt](sites/nostv.pt) | 🟢 | |
|
| [nostv.pt](sites/nostv.pt) | 🟢 | |
|
||||||
| [novacyprus.com](sites/novacyprus.com) | 🟢 | |
|
| [novacyprus.com](sites/novacyprus.com) | 🟢 | |
|
||||||
| [novasports.gr](sites/novasports.gr) | 🟢 | |
|
| [novasports.gr](sites/novasports.gr) | 🟢 | |
|
||||||
|
|
1
sites/nhl.com/__data__/content.json
Normal file
1
sites/nhl.com/__data__/content.json
Normal file
File diff suppressed because one or more lines are too long
10
sites/nhl.com/nhl.com.channels.xml
Normal file
10
sites/nhl.com/nhl.com.channels.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<channels>
|
||||||
|
<!--
|
||||||
|
`site_id` is not relevant for this configuration as nhl.com only has a guide for one channel.
|
||||||
|
nonetheless I elected to use "network" here because:
|
||||||
|
1) a blank value causes the record to be skipped
|
||||||
|
2) "network" is a keyword in the API endpoint
|
||||||
|
-->
|
||||||
|
<channel site="nhl.com" lang="en" xmltv_id="NHLNetwork.us" site_id="network">NHL Network</channel>
|
||||||
|
</channels>
|
45
sites/nhl.com/nhl.com.config.js
Normal file
45
sites/nhl.com/nhl.com.config.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'nhl.com',
|
||||||
|
// I'm not sure what `endDate` represents but they only return 1 day of
|
||||||
|
// results, with `endTime`s ocassionally in the following day.
|
||||||
|
days: 1,
|
||||||
|
url: ({ date }) => `https://api-web.nhle.com/v1/network/tv-schedule/${date.toJSON().split("T")[0]}`,
|
||||||
|
parser({ content }) {
|
||||||
|
const programs = []
|
||||||
|
const items = parseItems(content)
|
||||||
|
for (const item of items) {
|
||||||
|
programs.push({
|
||||||
|
title: item.title,
|
||||||
|
description: item.description === item.title ? undefined : item.description,
|
||||||
|
category: item.title === "NHL Game" ? "Sports event" : "Sports non-event",
|
||||||
|
// image: parseImage(item),
|
||||||
|
start: parseStart(item),
|
||||||
|
stop: parseStop(item)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unfortunately I couldn't determine how these are
|
||||||
|
// supposed to be formatted. Pointers appreciated!
|
||||||
|
// function parseImage(item) {
|
||||||
|
// const uri = item.broadcastImageUrl
|
||||||
|
|
||||||
|
// return uri ? `https://???/${uri}` : null
|
||||||
|
// }
|
||||||
|
|
||||||
|
function parseStart(item) {
|
||||||
|
return dayjs(item.startTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStop(item) {
|
||||||
|
return dayjs(item.endTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
return JSON.parse(content).broadcasts
|
||||||
|
}
|
44
sites/nhl.com/nhl.com.test.js
Normal file
44
sites/nhl.com/nhl.com.test.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
const { parser, url } = require('./nhl.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('2024-11-21', 'YYYY-MM-DD').startOf('d')
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ date })).toBe(
|
||||||
|
'https://api-web.nhle.com/v1/network/tv-schedule/2024-11-21'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||||
|
let results = parser({ content, date })
|
||||||
|
results = results.map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
start: '2024-11-21T12:00:00.000Z',
|
||||||
|
stop: '2024-11-21T13:00:00.000Z',
|
||||||
|
title: 'On The Fly',
|
||||||
|
category: 'Sports non-event',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const results = parser({ content: JSON.stringify({
|
||||||
|
// extra props not necessary but they form a valid response
|
||||||
|
date: "2024-11-21",
|
||||||
|
startDate: "2024-11-07",
|
||||||
|
endDate: "2024-12-05",
|
||||||
|
broadcasts: [],
|
||||||
|
}) })
|
||||||
|
expect(results).toMatchObject([])
|
||||||
|
})
|
15
sites/nhl.com/readme.md
Normal file
15
sites/nhl.com/readme.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# nhl.com
|
||||||
|
|
||||||
|
https://www.nhl.com/nhl-network/programming-schedule
|
||||||
|
|
||||||
|
### Download the guide
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run grab -- --site=nhl.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm test -- nhl.com
|
||||||
|
```
|
Loading…
Add table
Add a link
Reference in a new issue