mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Create toonamiaftermath.com.config.js
This commit is contained in:
parent
e4239b2b29
commit
26c172f6d3
1 changed files with 53 additions and 0 deletions
53
sites/toonamiaftermath.com/toonamiaftermath.com.config.js
Normal file
53
sites/toonamiaftermath.com/toonamiaftermath.com.config.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'
|
||||||
|
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
|
const API_ENDPOINT = `https://api.toonamiaftermath.com`
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'toonamiaftermath.com',
|
||||||
|
async url({ channel, date }) {
|
||||||
|
const playlists = await axios
|
||||||
|
.get(
|
||||||
|
`${API_ENDPOINT}/playlists?scheduleName=${channel.site_id}&startDate=${date
|
||||||
|
.add(1, 'd')
|
||||||
|
.toJSON()}&thisWeek=true&weekStartDay=monday`
|
||||||
|
)
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.error)
|
||||||
|
|
||||||
|
const playlist = playlists.find(p => date.isSame(p.startDate, 'day'))
|
||||||
|
|
||||||
|
return `https://api.toonamiaftermath.com/playlist?id=${playlist._id}&addInfo=true`
|
||||||
|
},
|
||||||
|
parser({ content, date }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content, date)
|
||||||
|
items.forEach(item => {
|
||||||
|
programs.push({
|
||||||
|
title: item.name,
|
||||||
|
sub_title: item?.info?.episode,
|
||||||
|
icon: item?.info?.image,
|
||||||
|
start: dayjs(item.startDate),
|
||||||
|
stop: dayjs(item.endDate)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, date) {
|
||||||
|
if (!content) return []
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
const blocks = data?.playlist?.blocks || []
|
||||||
|
|
||||||
|
return blocks
|
||||||
|
.reduce((acc, curr) => {
|
||||||
|
acc = acc.concat(curr.mediaList)
|
||||||
|
|
||||||
|
return acc
|
||||||
|
}, [])
|
||||||
|
.filter(i => date.isSame(i.startDate, 'day'))
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue