mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update directv.com.config.js
This commit is contained in:
parent
d78dab4d73
commit
9d99b8528d
1 changed files with 19 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
|
@ -13,26 +14,39 @@ module.exports = {
|
|||
logo({ channel }) {
|
||||
return channel.logo
|
||||
},
|
||||
parser({ content }) {
|
||||
async parser({ content }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
if (item.programID === '-1') return
|
||||
for (let item of items) {
|
||||
if (item.programID === '-1') continue
|
||||
const detail = await loadProgramDetail(item.programID)
|
||||
const start = parseStart(item)
|
||||
const stop = start.add(item.duration, 'm')
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
description: parseDescription(detail),
|
||||
category: item.subcategoryList,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseDescription(detail) {
|
||||
return detail ? detail.description : null
|
||||
}
|
||||
|
||||
function loadProgramDetail(programID) {
|
||||
return axios
|
||||
.get(`https://www.directv.com/json/program/flip/${programID}`)
|
||||
.then(r => r.data)
|
||||
.then(d => d.programDetail)
|
||||
.catch(console.err)
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.utc(item.airTime)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue