mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create stod2.is.config.js
This commit is contained in:
parent
f07514b3e4
commit
01419410eb
1 changed files with 68 additions and 0 deletions
68
sites/stod2.is/stod2.is.config.js
Normal file
68
sites/stod2.is/stod2.is.config.js
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'stod2.is',
|
||||||
|
channels: 'stod2.is.channels.xml',
|
||||||
|
days: 7,
|
||||||
|
request: {
|
||||||
|
cache: {
|
||||||
|
ttl: 60 * 60 * 1000 // 1 hour
|
||||||
|
}
|
||||||
|
},
|
||||||
|
url({ channel, date }) {
|
||||||
|
return `https://api.stod2.is/dagskra/api/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||||
|
},
|
||||||
|
parser: function ({ content }) {
|
||||||
|
let data
|
||||||
|
try {
|
||||||
|
data = JSON.parse(content)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error parsing JSON:', error)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
const programs = []
|
||||||
|
|
||||||
|
if (data && Array.isArray(data)) {
|
||||||
|
data.forEach(item => {
|
||||||
|
if (!item) return
|
||||||
|
const start = dayjs.utc(item.upphaf)
|
||||||
|
const stop = start.add(item.slott, 'm')
|
||||||
|
|
||||||
|
programs.push({
|
||||||
|
title: item.isltitill,
|
||||||
|
sub_title: item.undirtitill,
|
||||||
|
description: item.lysing,
|
||||||
|
actors: item.adalhlutverk,
|
||||||
|
directors: item.leikstjori,
|
||||||
|
start: start.toISOString,
|
||||||
|
stop: stop.toISOString
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return programs
|
||||||
|
},
|
||||||
|
async channels() {
|
||||||
|
try {
|
||||||
|
const response = await axios.get('https://api.stod2.is/dagskra/api')
|
||||||
|
if (!response.data || !Array.isArray(response.data)) {
|
||||||
|
console.error('Error: No channels data found')
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return response.data.map(item => {
|
||||||
|
return {
|
||||||
|
lang: 'is',
|
||||||
|
site_id: item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching channels:', error)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue