mirror of
https://github.com/iptv-org/epg
synced 2026-09-14 04:56:25 -04:00
fix tv.trueid.net
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const axios = require('axios')
|
||||
const cheerio = require('cheerio')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
@@ -7,8 +9,12 @@ module.exports = {
|
||||
delay: 1000,
|
||||
site: 'tv.trueid.net',
|
||||
days: 1,
|
||||
url({ channel }) {
|
||||
return `https://tv.trueid.net/_next/data/1380644e0f1fb6b14c82894a0c682d147e015c9d/th-${channel.lang}.json?channelSlug=${channel.site_id}&path=${channel.site_id}`
|
||||
buildId: undefined,
|
||||
async url({ channel }) {
|
||||
if (module.exports.buildId === undefined) {
|
||||
module.exports.buildId = await module.exports.fetchBuildId()
|
||||
}
|
||||
return `https://tv.trueid.net/_next/data/${module.exports.buildId}/th-${channel.lang}.json?channelSlug=${channel.site_id}&path=${channel.site_id}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
const programs = []
|
||||
@@ -24,30 +30,46 @@ module.exports = {
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ token, lang = 'en' }) {
|
||||
const axios = require('axios')
|
||||
const ACCESS_TOKEN = token
|
||||
? token
|
||||
: 'MTM4MDY0NGUwZjFmYjZiMTRjODI4OTRhMGM2ODJkMTQ3ZTAxNWM5ZDoxZmI2YjE0YzgyODk0YTBjNjgyZDE0N2UwMTVjOWQ='
|
||||
async channels({ lang = 'en' }) {
|
||||
if (module.exports.buildId === undefined) {
|
||||
module.exports.buildId = await module.exports.fetchBuildId()
|
||||
}
|
||||
|
||||
const data = await axios
|
||||
.get(`https://tv.trueid.net/api/channel/getChannelListByAllCate?lang=${lang}&country=th`, {
|
||||
headers: {
|
||||
authorization: `Basic ${ACCESS_TOKEN}`
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.get(`https://tv.trueid.net/_next/data/${module.exports.buildId}/th-${lang}.json`)
|
||||
.then(r => r.data?.pageProps)
|
||||
.catch(console.error)
|
||||
|
||||
return data.data.channelsList
|
||||
.find(i => i.catSlug === 'TrueID : All')
|
||||
.channels.map(item => {
|
||||
if (!data?.channelList) {
|
||||
return []
|
||||
}
|
||||
|
||||
return data.channelList
|
||||
.filter(i => i.content_type === 'livetv')
|
||||
.map(item => {
|
||||
return {
|
||||
lang,
|
||||
site_id: item.slug,
|
||||
name: item.title
|
||||
name: item.title,
|
||||
logo: item.thumb
|
||||
}
|
||||
})
|
||||
},
|
||||
// Since the website uses Next.js, each time the developers deploy a new version, a new build ID is generated.
|
||||
// This permits us to always fetch the proper build ID before making requests.
|
||||
async fetchBuildId() {
|
||||
const data = await axios
|
||||
.get('https://tv.trueid.net/th-en')
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
if (data) {
|
||||
const $ = cheerio.load(data)
|
||||
const nextData = JSON.parse($('#__NEXT_DATA__').text())
|
||||
return nextData?.buildId || null
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user