mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create directv.com.config.js
This commit is contained in:
parent
40f1890efb
commit
566b5b561d
1 changed files with 47 additions and 0 deletions
47
sites/directv.com/directv.com.config.js
Normal file
47
sites/directv.com/directv.com.config.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
request: {
|
||||
timeout: 15000
|
||||
},
|
||||
site: 'directv.com',
|
||||
url({ channel, date }) {
|
||||
return `https://www.directv.com/json/channelschedule?channels=${
|
||||
channel.site_id
|
||||
}&startTime=${date.format()}&hours=24`
|
||||
},
|
||||
logo({ channel }) {
|
||||
return channel.logo
|
||||
},
|
||||
parser({ content }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
if (item.programID === '-1') return
|
||||
const start = parseStart(item)
|
||||
const stop = start.add(item.duration, 'm')
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
category: item.subcategoryList,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.utc(item.airTime)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return data && data.schedule && data.schedule[0] ? data.schedule[0].schedules : []
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue