mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update tvtv.us.config.js
This commit is contained in:
parent
c0d4c631f8
commit
42ce11a6ba
1 changed files with 14 additions and 27 deletions
|
@ -1,42 +1,24 @@
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'tvtv.us',
|
site: 'tvtv.us',
|
||||||
days: 2,
|
days: 2,
|
||||||
url: function ({ date, channel }) {
|
url({ date, channel }) {
|
||||||
if (!dayjs.isDayjs(date)) {
|
|
||||||
throw new Error('Invalid date object passed to url function')
|
|
||||||
}
|
|
||||||
|
|
||||||
return `https://www.tvtv.us/api/v1/lineup/USA-NY71652-X/grid/${date.toJSON()}/${date
|
return `https://www.tvtv.us/api/v1/lineup/USA-NY71652-X/grid/${date.toJSON()}/${date
|
||||||
.add(1, 'day')
|
.add(1, 'day')
|
||||||
.toJSON()}/${channel.site_id}`
|
.toJSON()}/${channel.site_id}`
|
||||||
},
|
},
|
||||||
request: {
|
parser({ content }) {
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
Accept: '*/*',
|
|
||||||
Connection: 'keep-alive',
|
|
||||||
'User-Agent':
|
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
|
|
||||||
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
|
|
||||||
'sec-ch-ua-mobile': '?0',
|
|
||||||
'sec-ch-ua-platform': '"Windows"'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
parser: function ({ content }) {
|
|
||||||
let programs = []
|
let programs = []
|
||||||
|
|
||||||
const items = parseItems(content)
|
const items = parseItems(content)
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const start = dayjs.utc(item.startTime)
|
const start = dayjs(item.startTime)
|
||||||
const stop = start.add(item.runTime, 'minute')
|
const stop = start.add(item.duration, 'minute')
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.title,
|
title: item.title,
|
||||||
description: item.subtitle,
|
subtitle: item.subtitle || null,
|
||||||
start,
|
start,
|
||||||
stop
|
stop
|
||||||
})
|
})
|
||||||
|
@ -47,7 +29,12 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content) {
|
function parseItems(content) {
|
||||||
const json = JSON.parse(content)
|
try {
|
||||||
if (!json.length) return []
|
const json = JSON.parse(content)
|
||||||
return json[0]
|
if (!json.length) return []
|
||||||
|
|
||||||
|
return json[0]
|
||||||
|
} catch {
|
||||||
|
return []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue