mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create tv.trueid.net.config.js
This commit is contained in:
parent
6dc7f35aaa
commit
7ba78abe1a
1 changed files with 70 additions and 0 deletions
70
sites/tv.trueid.net/tv.trueid.net.config.js
Normal file
70
sites/tv.trueid.net/tv.trueid.net.config.js
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
const jsdom = require('jsdom')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
request: {
|
||||||
|
timeout: 90000,
|
||||||
|
jar: null
|
||||||
|
},
|
||||||
|
site: 'tv.trueid.net',
|
||||||
|
channels: 'tv.trueid.net.channels.xml',
|
||||||
|
url: function ({ channel, date }) {
|
||||||
|
return `https://tv.trueid.net/tvguide/all/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||||
|
},
|
||||||
|
logo: function ({ content, channel }) {
|
||||||
|
const data = parseContent(content, channel)
|
||||||
|
|
||||||
|
return data ? data.logo : null
|
||||||
|
},
|
||||||
|
parser: function ({ content, channel }) {
|
||||||
|
let programs = []
|
||||||
|
const data = parseContent(content, channel)
|
||||||
|
const items = parseItems(data)
|
||||||
|
items.forEach(item => {
|
||||||
|
const start = parseStart(item)
|
||||||
|
const stop = parseStop(item)
|
||||||
|
|
||||||
|
programs.push({
|
||||||
|
title: item.title,
|
||||||
|
icon: parseIcon(item),
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseIcon(item) {
|
||||||
|
return item.detail ? item.detail.thumb : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart(item) {
|
||||||
|
return item.detail ? dayjs.utc(item.detail.start_date) : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStop(item) {
|
||||||
|
return item.detail ? dayjs.utc(item.detail.end_date) : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseContent(content, channel) {
|
||||||
|
const virtualConsole = new jsdom.VirtualConsole()
|
||||||
|
virtualConsole.sendTo(console, { omitJSDOMErrors: true })
|
||||||
|
const dom = new jsdom.JSDOM(content, { virtualConsole })
|
||||||
|
const elem = dom.window.document.getElementById('__NEXT_DATA__') || { textContent: '' }
|
||||||
|
if (!elem.textContent) return null
|
||||||
|
const data = JSON.parse(elem.textContent)
|
||||||
|
const channels = data.props?.pageProps?.listEPG?.data || []
|
||||||
|
|
||||||
|
return channels.find(ch => ch.slug === channel.site_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(data) {
|
||||||
|
if (!data) return []
|
||||||
|
|
||||||
|
return data.programList || []
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue