provider fixes + version update

This commit is contained in:
David Claeys 2024-12-20 08:26:15 +01:00
parent 4ba2fce7cf
commit b042f5ac8e
3 changed files with 43 additions and 38 deletions

View File

@ -41,8 +41,8 @@ This the list of the provided custom fixes :
| Provider | Author(s) | Status |
|------------------|------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| movistarplus.es | [davidclaeysquinones](https://github.com/davidclaeysquinones) | [PR](https://github.com/iptv-org/epg/pull/2440) pending approval |
| orangetv.es | [fraudiay79](https://github.com/fraudiay79) and [davidclaeysquinones](https://github.com/davidclaeysquinones) | PR not submitted |
| pickx.be | [davidclaeysquinones](https://github.com/davidclaeysquinones) and [BellezaEmporium](https://github.com/BellezaEmporium) | [PR](https://github.com/iptv-org/epg/pull/2520) pending approval |
| orangetv.es | [fraudiay79](https://github.com/fraudiay79) and [davidclaeysquinones](https://github.com/davidclaeysquinones) | [PR](https://github.com/iptv-org/epg/pull/2485) not in draft stage |
| pickx.be | [davidclaeysquinones](https://github.com/davidclaeysquinones) and [BellezaEmporium](https://github.com/BellezaEmporium) | [PR](https://github.com/iptv-org/epg/pull/2525) merged since commit [fd91a9c] (https://github.com/iptv-org/epg/commit/fd91a9c532b476f6e192a564371d30e766b762ab) |
| telenet.tv | [davidclaeysquinones](https://github.com/davidclaeysquinones) | [PR](https://github.com/iptv-org/epg/pull/2429) merged since commit [fd382db](https://github.com/iptv-org/epg/commit/fd382db08da7a96150928b8dcfef115e29e661d3) |
| web.magentatv.de | [klausellus-wallace](https://github.com/klausellus-wallace) | [PR](https://github.com/iptv-org/epg/pull/2458) merged since commit [61afe09](https://github.com/iptv-org/epg/commit/61afe090b6e7892cc5426457d960e9452222f885) |
@ -153,4 +153,6 @@ Sometimes a new version of this image will be bound to the same source commit. T
- 1.0.30
[12-16-2024](https://github.com/iptv-org/epg/commit/b9bbd32d354315eb292e3b82da09785e575a9781)
- 1.0.31
[12-17-2024](https://github.com/iptv-org/epg/commit/7237a62d94c5691f7f467b334f846efce93b08ff)<br>Fix for Pickx.be + mayor program updates
[12-17-2024](https://github.com/iptv-org/epg/commit/7237a62d94c5691f7f467b334f846efce93b08ff)<br>Fix for Pickx.be + mayor program updates
- 1.0.32
[12-20-2024](https://github.com/iptv-org/epg/commit/f00d53cb7be3cd7f6625897709cab005fe1b3dc4)

View File

@ -1,16 +1,17 @@
// credit for this fix goes to fraudiay79 and to davidclaeysquinones for their work
// credit for this fix goes to fraudiay79, BellezaEmporium and to davidclaeysquinones for their work
// the PR is not submitted since the test suite for this provider needs to be developed
// for now the source code can be found at https://github.com/davidclaeysquinones/epg/tree/orangetv.orange.es
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,
@ -23,7 +24,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(
@ -37,23 +40,23 @@ 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,
description: item.description,
category: parseGenres(item),
season: item.seriesSeason || null,
episode: item.episodeId || null,
icon: parseIcon(item),
@ -94,14 +97,21 @@ function parseIcon(item){
return ''
}
function parseGenres(item){
return item.genres.map(i => i.name);
}
function parseItems(content, channel) {
const json = typeof content === 'string' ? JSON.parse(content) : typeof content === 'object' ? content : []
const json = typeof content === 'string' ? JSON.parse(content) : Array.isArray(content) ? content : []
if (!Array.isArray(json)) {
return [];
}
const channelData = json.find(i => i.channelExternalId == channel.site_id);
if(!channelData)
return [];
return channelData.programs;
}

View File

@ -1,33 +1,26 @@
// credit for this fix goes to davidclaeysquinones for his PR on https://github.com/iptv-org/epg/pull/2430, https://github.com/iptv-org/epg/pull/2520 and to BellezaEmporium for his PR on https://github.com/iptv-org/epg/pull/2480
// credit for this fix goes to davidclaeysquinones for his PR on https://github.com/iptv-org/epg/pull/2430, https://github.com/iptv-org/epg/pull/2520 and to BellezaEmporium for his PR on https://github.com/iptv-org/epg/pull/2480, https://github.com/iptv-org/epg/pull/2525
const axios = require('axios')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
let apiVersion
let isApiVersionFetched = false
;(async () => {
try {
await fetchApiVersion()
isApiVersionFetched = true
} catch (error) {
console.error('Error during script initialization:', error)
}
})()
dayjs.extend(utc)
module.exports = {
site: 'pickx.be',
days: 2,
apiVersion: function () {
setApiVersion: function (version) {
apiVersion = version
},
getApiVersion: function () {
return apiVersion
},
fetchApiVersion: fetchApiVersion, // Export fetchApiVersion
fetchApiVersion: fetchApiVersion,
url: async function ({ channel, date }) {
while (!isApiVersionFetched) {
await new Promise(resolve => setTimeout(resolve, 100)) // Wait for 100 milliseconds
if (!apiVersion) {
await fetchApiVersion()
}
return `https://px-epg.azureedge.net/airings/${apiVersion}/${date.format(
'YYYY-MM-DD'
@ -118,7 +111,7 @@ module.exports = {
}`
}
const result = await axios
.post('https://api.proximusmwc.be/tiams/v2/graphql', query)
.post('https://api.proximusmwc.be/tiams/v3/graphql', query)
.then(r => r.data)
.catch(console.error)
@ -142,7 +135,7 @@ function fetchApiVersion() {
return new Promise(async (resolve, reject) => {
try {
// you'll never find what happened here :)
// load pickx bundle and get react version hash (regex).
// load the pickx page and get the hash from the MWC configuration.
// it's not the best way to get the version but it's the only way to get it.
const hashUrl = 'https://www.pickx.be/nl/televisie/tv-gids';
@ -180,4 +173,4 @@ function fetchApiVersion() {
reject(error)
}
})
}
}