mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
fix config
This commit is contained in:
parent
53e05d1bce
commit
b0cf90be1f
1 changed files with 17 additions and 15 deletions
|
@ -1,12 +1,13 @@
|
|||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const axios = require('axios')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
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_IMAGE_ENDPOINT = 'https://pc.orangetv.orange.es/pc/api/rtv/v1/images'
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
site: 'orangetv.es',
|
||||
days: 2,
|
||||
|
@ -19,7 +20,9 @@ module.exports = {
|
|||
return `${API_PROGRAM_ENDPOINT}/${date.format('YYYYMMDD')}_8h_1.json`
|
||||
},
|
||||
async parser({ content, channel, date }) {
|
||||
let items = []
|
||||
let programs = []
|
||||
let items = parseItems(content, channel)
|
||||
if (!items.length) return programs
|
||||
|
||||
const promises = [
|
||||
axios.get(
|
||||
|
@ -33,19 +36,18 @@ module.exports = {
|
|||
),
|
||||
]
|
||||
|
||||
await Promise.all(promises)
|
||||
.then(results => {
|
||||
results.forEach(r => {
|
||||
const responseContent = r.data
|
||||
items = items.concat(parseItems(responseContent, channel))
|
||||
await Promise.allSettled(promises)
|
||||
.then(results => {
|
||||
results.forEach(r => {
|
||||
if (r.status === 'fulfilled') {
|
||||
const parsed = parseItems(r.value.data, channel)
|
||||
|
||||
items = items.filter((item, index) => items.findIndex(oi => oi.id === item.id) === index).concat(parsed)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(console.error)
|
||||
.catch(console.error)
|
||||
|
||||
// remove duplicates
|
||||
items = items.filter((item, index) => items.findIndex(oi => oi.id === item.id) === index);
|
||||
|
||||
let programs = []
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.name,
|
||||
|
@ -100,4 +102,4 @@ function parseItems(content, channel) {
|
|||
|
||||
|
||||
return channelData.programs;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue