mirror of
https://github.com/iptv-org/epg
synced 2026-05-08 10:27:06 -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:
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
|
||||
}
|
||||
Reference in New Issue
Block a user