Merge pull request #1 from Mauricio300808/Fix-tvtv.us-issue.-adding-headers

Fix tvtv.us issue. adding headers
This commit is contained in:
Mauricio300808 2024-11-20 15:43:15 -06:00 committed by GitHub
commit 4979d2f178
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
const dayjs = require('dayjs')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
@ -8,17 +8,33 @@ module.exports = {
delay: 1500, // 1500 ms (otherwise the server returns error 429: https://github.com/iptv-org/epg/issues/2176)
days: 2,
url: function ({ 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
.add(1, 'd')
.add(1, 'day')
.toJSON()}/${channel.site_id}`
},
request: {
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 = []
const items = parseItems(content)
items.forEach(item => {
const start = dayjs.utc(item.startTime)
const stop = start.add(item.runTime, 'm')
const stop = start.add(item.runTime, 'minute')
programs.push({
title: item.title,
description: item.subtitle,