mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Create frikanalen.no.config.js
This commit is contained in:
parent
ced9c2e54d
commit
5e8c8730a0
1 changed files with 51 additions and 0 deletions
51
sites/frikanalen.no/frikanalen.no.config.js
Normal file
51
sites/frikanalen.no/frikanalen.no.config.js
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'frikanalen.no',
|
||||||
|
url({ date }) {
|
||||||
|
return `https://frikanalen.no/api/scheduleitems/?date=${date.format(
|
||||||
|
'YYYY-MM-DD'
|
||||||
|
)}&format=json&limit=100`
|
||||||
|
},
|
||||||
|
parser({ content }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content)
|
||||||
|
items.forEach(item => {
|
||||||
|
programs.push({
|
||||||
|
title: parseTitle(item),
|
||||||
|
category: parseCategory(item),
|
||||||
|
description: parseDescription(item),
|
||||||
|
start: parseStart(item),
|
||||||
|
stop: parseStop(item)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle(item) {
|
||||||
|
return item.video.name
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseCategory(item) {
|
||||||
|
return item.video.categories
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDescription(item) {
|
||||||
|
return item.video.header
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart(item) {
|
||||||
|
return dayjs(item.starttime)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStop(item) {
|
||||||
|
return dayjs(item.endtime)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
|
||||||
|
return data && Array.isArray(data.results) ? data.results : []
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue