mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update gatotv.com.config.js
This commit is contained in:
parent
9d460e2469
commit
ee8f80a281
1 changed files with 25 additions and 22 deletions
|
@ -1,37 +1,43 @@
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const cheerio = require('cheerio')
|
const cheerio = require('cheerio')
|
||||||
|
const url = require('url')
|
||||||
|
const path = require('path')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
var url = require('url')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
var path = require('path')
|
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'gatotv.com',
|
site: 'gatotv.com',
|
||||||
days: 2,
|
days: 2,
|
||||||
url: function ({ channel, date }) {
|
url({ channel, date }) {
|
||||||
return `https://www.gatotv.com/canal/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
return `https://www.gatotv.com/canal/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||||
},
|
},
|
||||||
parser: function ({ content, date }) {
|
parser({ content, date }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
const items = parseItems(content)
|
const items = parseItems(content)
|
||||||
|
date = date.subtract(1, 'd')
|
||||||
items.forEach((item, index) => {
|
items.forEach((item, index) => {
|
||||||
const prev = programs[programs.length - 1]
|
const prev = programs[programs.length - 1]
|
||||||
const $item = cheerio.load(item)
|
const $item = cheerio.load(item)
|
||||||
let start = parseStart($item, date)
|
let start = parseStart($item, date)
|
||||||
if (prev && start.isBefore(prev.stop)) {
|
if (prev) {
|
||||||
start = start.add(1, 'd')
|
if (start.isBefore(prev.start)) {
|
||||||
date = date.add(1, 'd')
|
start = start.add(1, 'd')
|
||||||
} else if (!prev && start.hour() > 12) {
|
date = date.add(1, 'd')
|
||||||
start = start.subtract(1, 'd')
|
}
|
||||||
date = date.subtract(1, 'd')
|
prev.stop = start
|
||||||
}
|
}
|
||||||
let stop = parseStop($item, date)
|
let stop = parseStop($item, start)
|
||||||
if (stop.isBefore(start)) {
|
if (stop.isBefore(start)) {
|
||||||
stop = stop.add(1, 'd')
|
stop = stop.add(1, 'd')
|
||||||
date = date.add(1, 'd')
|
date = date.add(1, 'd')
|
||||||
}
|
}
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: parseTitle($item),
|
title: parseTitle($item),
|
||||||
description: parseDescription($item),
|
description: parseDescription($item),
|
||||||
|
@ -43,15 +49,16 @@ module.exports = {
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
},
|
},
|
||||||
async channels({ country }) {
|
async channels() {
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get(`https://www.gatotv.com/guia_tv/${country}`)
|
.get(`https://www.gatotv.com/guia_tv/completa`)
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.catch(console.log)
|
.catch(console.log)
|
||||||
|
|
||||||
const $ = cheerio.load(data)
|
const $ = cheerio.load(data)
|
||||||
const items = $('.tbl_EPG_row,.tbl_EPG_rowAlternate').toArray()
|
const items = $('.tbl_EPG_row,.tbl_EPG_rowAlternate').toArray()
|
||||||
const channels = items.map(item => {
|
|
||||||
|
return items.map(item => {
|
||||||
const $item = cheerio.load(item)
|
const $item = cheerio.load(item)
|
||||||
const link = $item('td:nth-child(1) > div:nth-child(2) > a:nth-child(3)').attr('href')
|
const link = $item('td:nth-child(1) > div:nth-child(2) > a:nth-child(3)').attr('href')
|
||||||
const parsed = url.parse(link)
|
const parsed = url.parse(link)
|
||||||
|
@ -62,8 +69,6 @@ module.exports = {
|
||||||
name: $item('td:nth-child(1) > div:nth-child(2) > a:nth-child(3)').text()
|
name: $item('td:nth-child(1) > div:nth-child(2) > a:nth-child(3)').text()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return channels
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,17 +85,15 @@ function parseIcon($item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart($item, date) {
|
function parseStart($item, date) {
|
||||||
let time = $item('td:nth-child(1) > div > time').attr('datetime')
|
const time = $item('td:nth-child(1) > div > time').attr('datetime')
|
||||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
|
||||||
|
|
||||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'America/New_York')
|
return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'EST')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStop($item, date) {
|
function parseStop($item, date) {
|
||||||
let time = $item('td:nth-child(2) > div > time').attr('datetime')
|
const time = $item('td:nth-child(2) > div > time').attr('datetime')
|
||||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
|
||||||
|
|
||||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'America/New_York')
|
return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'EST')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content) {
|
function parseItems(content) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue