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 dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
|
||||||
|
@ -13,26 +14,39 @@ module.exports = {
|
||||||
logo({ channel }) {
|
logo({ channel }) {
|
||||||
return channel.logo
|
return channel.logo
|
||||||
},
|
},
|
||||||
parser({ content }) {
|
async parser({ content }) {
|
||||||
const programs = []
|
const programs = []
|
||||||
const items = parseItems(content)
|
const items = parseItems(content)
|
||||||
items.forEach(item => {
|
for (let item of items) {
|
||||||
if (item.programID === '-1') return
|
if (item.programID === '-1') continue
|
||||||
|
const detail = await loadProgramDetail(item.programID)
|
||||||
const start = parseStart(item)
|
const start = parseStart(item)
|
||||||
const stop = start.add(item.duration, 'm')
|
const stop = start.add(item.duration, 'm')
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.title,
|
title: item.title,
|
||||||
description: item.description,
|
description: parseDescription(detail),
|
||||||
category: item.subcategoryList,
|
category: item.subcategoryList,
|
||||||
start,
|
start,
|
||||||
stop
|
stop
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
return programs
|
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) {
|
function parseStart(item) {
|
||||||
return dayjs.utc(item.airTime)
|
return dayjs.utc(item.airTime)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue