update custom fixes to latest code

This commit is contained in:
david committed 2026-10-27 10:43:05 +01:00
1 parent 3876463747
commit bcfd38cb19
3 files changed
+282 -211

No files matched your search

@@ -9,10 +9,12 @@ dayjs.extend(utc)
doFetch.setDebugger(debug)
const API_PROGRAM_ENDPOINT = 'https://epg.orangetv.orange.es/epg/Smartphone_Android/1_PRO'
const API_CHANNEL_ENDPOINT =
'https://pc.orangetv.orange.es/pc/api/rtv/v1/GetChannelList?bouquet_id=1&model_external_id=PC&filter_unsupported_channels=false&client=json'
const API_PROGRAM_ENDPOINT = 'https://epg.orangetv.orange.es/epg/SmartTV_Android/1_PRO'
const API_IMAGE_ENDPOINT = 'https://pc.orangetv.orange.es/pc/api/rtv/v1/images'
const API_CHANNEL_ENDPOINT =
'https://pc.orangetv.orange.es/pc/api/rtv/v1/GetChannelList?bouquet_external_id=1_PRO&model_external_id=PC&filter_unsupported_channels=true&max_pr_level=8&client=json'
const caches = {}
module.exports = {
site: 'orangetv.orange.es',
@@ -25,20 +27,31 @@ module.exports = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36'
}
},
url: function({ date, segment = 1 }) {
return `${API_PROGRAM_ENDPOINT}/${date.format('YYYYMMDD')}_8h_${segment}.json`
url({ date }) {
return segmentUrl(date)
},
async parser({ content, channel, date }) {
const programs = []
const items = parseItems(content, channel)
if (items.length) {
const queues = [
module.exports.url({ date, segment: 2 }),
module.exports.url({ date, segment: 3 })
]
await doFetch(queues, (url, res) => {
const queues = []
// fetch other segments or use cache if exist
for (let i = 2; i <= 3; i++) {
const url = segmentUrl(date, i)
if (caches[url] !== undefined) {
items.push(...parseItems(caches[url], channel))
} else {
queues.push({ url, params: module.exports.request })
}
}
if (queues.length) {
await doFetch(queues, (queue, res) => {
if (caches[queue.url] === undefined) {
caches[queue.url] = res
}
items.push(...parseItems(res, channel))
})
}
if (items.length) {
programs.push(
...items.map(item => {
return {
@@ -75,6 +88,10 @@ module.exports = {
}
}
function segmentUrl(date, segment = 1) {
return `${API_PROGRAM_ENDPOINT}/${date.format('YYYYMMDD')}_8h_${segment}.json`
}
function parseIcon(item) {
if (item.attachments.length) {
const cover = item.attachments.find(i => i.name.match(/cover/i))
@@ -94,7 +111,7 @@ function parseItems(content, channel) {
typeof content === 'string' ? JSON.parse(content) : Array.isArray(content) ? content : []
if (Array.isArray(json)) {
json
.filter(i => i.channelExternalId === channel.site_id)
.filter(i => String(i.channelExternalId) === String(channel.site_id))
.forEach(i => {
result.push(...i.programs)
})