Compare commits

...
3 Commits
Author SHA1 Message Date
david 8edb33819e update readme
Build docker container / build (push) Successful in 15m56s
2026-10-29 09:29:05 +01:00
david 6fe29e4d71 update readme
Build docker container / build (push) Successful in 2m51s
2026-10-27 12:25:57 +01:00
david 0ff4dc7c7a fix issue with custom fix 2026-10-27 12:25:05 +01:00
3 changed files with 222 additions and 169 deletions

No files matched your search

+5
View File
@@ -290,3 +290,8 @@ Sometimes a new version of this image will be bound to the same source commit. T
- 1.0.94 - 1.0.94
[10-26-2026](https://github.com/iptv-org/epg/commit/2c3e24fdab86140181878af00e01e9b440962d9b) [10-26-2026](https://github.com/iptv-org/epg/commit/2c3e24fdab86140181878af00e01e9b440962d9b)
<br> Add fix for Pickx.be provder <br> Add fix for Pickx.be provder
- 1.0.95
[10-26-2026](https://github.com/iptv-org/epg/commit/2c3e24fdab86140181878af00e01e9b440962d9b)
<br> Solves issue in Telenet.TV custom fix
- 1.0.96
[10-29-2026](https://github.com/iptv-org/epg/commit/ae9cc64f9497c602ec2f6e17857ae38b3aa1ff05)
+213 -165
View File
@@ -1,215 +1,263 @@
//https://github.com/iptv-org/epg/blob/master/sites/web.magentatv.de/web.magentatv.de.config.js //https://github.com/iptv-org/epg/blob/master/sites/telenet.tv/telenet.tv.config.js
const axios = require('axios') const axios = require('axios')
const dayjs = require('dayjs') const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc') const doFetch = require('@ntlab/sfetch')
const customParseFormat = require('dayjs/plugin/customParseFormat')
let X_CSRFTOKEN const API_STATIC_ENDPOINT = 'https://staticqbr-prod-be.gnp.cloud.telenet.tv/eng/web/epg-service-lite/be'
let Cookie const API_PROD_ENDPOINT = 'https://spark-prod-be.gnp.cloud.telenet.tv/eng/web/linear-service/v2'
const cookiesToExtract = ['JSESSIONID', 'CSESSIONID', 'CSRFSESSION'] const API_IMAGE_ENDPOINT = 'https://staticqbr-prod-be.gnp.cloud.telenet.tv/image-service'
dayjs.extend(utc) // a segment holds 6 hours of guide for every channel at once, so it is kept around
dayjs.extend(customParseFormat) // and shared between all the channels of the same day
const segments = {}
// which day emitted an event, per channel, so a broadcast running past midnight is not repeated
// by the day it ends in
const claimed = {}
module.exports = { module.exports = {
site: 'web.magentatv.de', site: 'telenet.tv',
days: 2, days: 2,
url: 'https://api.prod.sngtv.magentatv.de/EPG/JSON/PlayBillList',
request: { request: {
method: 'POST', cache: {
async headers() { ttl: 60 * 60 * 1000 // 1 hour
return await setHeaders() }
}, },
data({ channel, date }) { url: function ({ date, channel, segment = 0 }) {
return `${API_STATIC_ENDPOINT}/${channel.lang}/events/segments/${date.format(
'YYYYMMDD'
)}${segment.toString().padStart(2, '0')}0000`
},
async parser({ content, channel, date }) {
const items = await loadItems({ content, channel, date })
if (!items.length) return []
const details = await loadProgramDetails(items, channel)
return items.map((item, index) => {
const detail = details[index] || {}
return { return {
count: -1, title: item.title,
isFillProgram: 1, subTitle: detail.episodeName || item.seriesName,
offset: 0, icon: parseIcon(item),
properties: [
{
include:
'endtime,genres,id,name,starttime,channelid,pictures,introduce,subName,seasonNum,subNum,cast,country,producedate,externalIds',
name: 'playbill'
}
],
type: 2,
begintime: date.format('YYYYMMDD000000'),
channelid: channel.site_id,
endtime: date.add(1, 'd').format('YYYYMMDD000000')
}
}
},
parser({ content }) {
const programs = []
const items = parseItems(content)
items.forEach(item => {
programs.push({
title: item.name,
description: item.introduce,
image: parseImage(item), image: parseImage(item),
icon: parseImage(item), description: detail.longDescription || detail.shortDescription,
category: parseCategory(item), category: detail.genres,
actors: detail.actors,
directors: detail.directors,
producers: detail.producers,
season: parseSeason(detail),
episode: parseEpisode(detail),
date: parseYear(detail),
country: detail.countryOfOrigin,
rating: parseRating(detail, item),
language: parseLanguages(detail, item),
subtitles: parseSubtitles(detail, item),
new: Boolean(detail.premiere || item.premiere),
start: parseStart(item), start: parseStart(item),
stop: parseStop(item), stop: parseStop(item)
sub_title: item.subName, }
season: item.seasonNum,
episode: item.subNum,
directors: parseDirectors(item),
producers: parseProducers(item),
adapters: parseAdapters(item),
country: item.country?.toUpperCase(),
date: item.producedate,
urls: parseUrls(item)
}) })
})
return programs
}, },
async channels() { async channels() {
const url = 'https://api.prod.sngtv.magentatv.de/EPG/JSON/AllChannel'
const body = {
channelNamespace: 2,
filterlist: [
{
key: 'IsHide',
value: '-1'
}
],
metaDataVer: 'Channel/1.1',
properties: [
{
include: '/channellist/logicalChannel/contentId,/channellist/logicalChannel/name',
name: 'logicalChannel'
}
],
returnSatChannel: 0
}
const params = {
headers: await setHeaders()
}
const data = await axios const data = await axios
.post(url, body, params) .get(`${API_PROD_ENDPOINT}/channels?cityId=28001&language=en&productClass=Orion-DASH`)
.then(r => r.data) .then(r => r.data)
.catch(console.log) .catch(console.log)
return data.channellist.map(item => { return data.map(item => {
return { return {
lang: 'de', lang: 'nl',
site_id: item.contentId, site_id: item.id,
name: item.name name: item.name
} }
}) })
} }
} }
function parseCategory(item) { async function loadItems({ content, channel, date }) {
return item.genres const urls = [0, 6, 12, 18].map(segment => module.exports.url({ date, channel, segment }))
? item.genres
.replace('und', ',') // the first segment has already been downloaded by the grabber itself
.split(',') cacheSegment(urls[0], content)
.map(i => i.trim())
: [] const missing = urls.filter(url => segments[url] === undefined)
if (missing.length) {
await doFetch(missing, (url, res) => cacheSegment(url, res))
}
const items = urls.flatMap(url => findEvents(segments[url], channel)).filter(isBroadcast)
// an event that spans a boundary is listed twice: by both segments, or by both days
return uniqueItems(items, channel, date)
} }
function parseDirectors(item) { // `res` is left out when a request fails, but only when sfetch is checking results, which is a
if (!item.cast || !item.cast.director) return [] // setting shared with the other sites using it, so every program is built from its event first
return item.cast.director async function loadProgramDetails(items, channel) {
.replace('und', ',') const details = []
.split(',') const queues = items
.map(i => i.trim()) .map((item, index) => ({ item, index }))
.filter(({ item }) => item.id)
.map(({ item, index }) => ({
url: `${API_PROD_ENDPOINT}/replayEvent/${item.id}?returnLinearContent=true&language=${channel.lang}`,
index
}))
if (queues.length) {
await doFetch(queues, (queue, res) => {
if (res) details[queue.index] = res
})
}
return details
} }
function parseProducers(item) { function cacheSegment(url, content) {
if (!item.cast || !item.cast.producer) return [] if (segments[url] !== undefined) return
return item.cast.producer const entries = parseEntries(content)
.replace('und', ',') // a failed download must not be cached, the next channel gets to retry it
.split(',') if (entries.length) segments[url] = entries
.map(i => i.trim())
} }
function parseAdapters(item) { // the grabber hands over the raw response, while axios has already parsed the ones fetched here
if (!item.cast || !item.cast.adaptor) return [] function parseEntries(content) {
return item.cast.adaptor if (!content) return []
.replace('und', ',') try {
.split(',') const data = Array.isArray(content.entries) ? content : JSON.parse(content)
.map(i => i.trim())
}
function parseUrls(item) { return Array.isArray(data.entries) ? data.entries : []
// currently only a imdb id is returned by the api, thus we can construct the url here } catch (err) {
if (!item.externalIds) return [] console.error(`Unable to parse guide: ${err.message}!`)
return JSON.parse(item.externalIds)
.filter(externalId => externalId.type === 'imdb' && externalId.id)
.map(externalId => ({ system: 'imdb', value: `https://www.imdb.com/title/${externalId.id}` }))
}
function parseImage(item) { return []
if (!Array.isArray(item.pictures) || !item.pictures.length) return null }
return item.pictures[0].href
} }
function parseStart(item) { function parseStart(item) {
return dayjs.utc(item.starttime, 'YYYY-MM-DD HH:mm:ss') return dayjs.unix(item.startTime)
} }
function parseStop(item) { function parseStop(item) {
return dayjs.utc(item.endtime, 'YYYY-MM-DD HH:mm:ss') return dayjs.unix(item.endTime)
} }
function parseItems(content) { // telenet fills the hours a channel is off air with "Geen uitzending", often several in a row.
const data = JSON.parse(content) // Nothing is behind them, so they are dropped and the guide simply has a hole there.
if (!data || !Array.isArray(data.playbilllist)) return [] function isBroadcast(item) {
return !/^geen uitzending\b/i.test(item.title || '')
return data.playbilllist
} }
async function fetchCookieAndToken() { function findEvents(entries, channel) {
// Only fetch the cookies and csrfToken if they are not already set if (!Array.isArray(entries)) return []
if (X_CSRFTOKEN && Cookie) { const channelData = entries.find(e => e.channelId === channel.site_id)
return if (!channelData) return []
}
try { return Array.isArray(channelData.events) ? channelData.events : []
const response = await axios.request({ }
url: 'https://api.prod.sngtv.magentatv.de/EPG/JSON/Authenticate',
params: { // Both guards are needed: the local set drops an event listed by two segments of this day, while
SID: 'firstup', // the claim drops one the previous day already emitted. Re-parsing a day it claimed itself stays
T: 'Windows_chrome_118' // idempotent, so parsing the same day twice keeps returning the same programs.
}, function uniqueItems(items, channel, date) {
method: 'POST', const day = date.format('YYYYMMDD')
data: '{"terminalid":"00:00:00:00:00:00","mac":"00:00:00:00:00:00","terminaltype":"WEBTV","utcEnable":1,"timezone":"Etc/GMT0","userType":3,"terminalvendor":"Unknown"}' const claimedByChannel = claimed[channel.site_id] || (claimed[channel.site_id] = new Map())
const seen = new Set()
return items.filter(item => {
if (seen.has(item.id)) return false
const owner = claimedByChannel.get(item.id)
if (owner !== undefined && owner !== day) return false
seen.add(item.id)
claimedByChannel.set(item.id, day)
return true
}) })
// Extract the cookies specified in cookiesToExtract
const setCookieHeader = response.headers['set-cookie'] || []
const extractedCookies = []
cookiesToExtract.forEach(cookieName => {
const regex = new RegExp(`${cookieName}=(.+?)(;|$)`)
const match = setCookieHeader.find(header => regex.test(header))
if (match) {
const cookieString = regex.exec(match)[0]
extractedCookies.push(cookieString)
}
})
// check if we recieved a csrfToken only then store the values
if (!response.data.csrfToken) {
console.log('csrfToken not found in the response.')
return
}
X_CSRFTOKEN = response.data.csrfToken
Cookie = extractedCookies.join(' ')
} catch (error) {
console.error(error)
}
} }
async function setHeaders() { function parseSeason(detail) {
await fetchCookieAndToken() if (!detail.seasonNumber) return null
if (String(detail.seasonNumber).length > 2) return null
return { X_CSRFTOKEN, Cookie } return detail.seasonNumber
}
function parseEpisode(detail) {
if (!detail.episodeNumber) return null
if (String(detail.episodeNumber).length > 3) return null
return detail.episodeNumber
}
function parseYear(detail) {
if (!detail.productionDate) return null
if (!/^\d{4}$/.test(String(detail.productionDate))) return null
return detail.productionDate
}
// the minimum age follows the Kijkwijzer (NICAM) classification
function parseRating(detail, item) {
const minimumAge = detail.minimumAge != null ? detail.minimumAge : item.minimumAge
if (minimumAge == null || minimumAge === '') {
if (detail.isAdult || item.isAdult) return { system: 'Kijkwijzer', value: '18' }
return null
}
return { system: 'Kijkwijzer', value: String(minimumAge) }
}
function parseLanguages(detail, item) {
return parseLangCodes(detail.audioLanguages || item.audioLanguages)
}
function parseSubtitles(detail, item) {
const captions = parseLangCodes(detail.captionLanguages || item.captionLanguages)
const signed = parseLangCodes(detail.signLanguages || item.signLanguages)
return [
...captions.map(language => ({ language })),
...signed.map(language => ({ type: 'deaf-signed', language }))
]
}
// the same language can be listed more than once, once per purpose (e.g. audio description)
function parseLangCodes(languages) {
if (!Array.isArray(languages)) return []
return [...new Set(languages.map(language => language.lang).filter(Boolean))]
}
// Three assets hang off one event id. Only the poster is always there: over a day of the guide,
// episodeStill answered for 91% of programmes and titleTreatment for 66%, and nothing in the event
// says which, so all three are emitted and a reader has to expect a 404.
//
// Poster first because the DTD asks for the most authoritative image first -- though Telenet's own
// player prefers the still, its bundle carrying the literal list ['episodeStill','posterTile'].
const IMAGE_INTENTS = [
// Key art cropped to 2:3, always from the season or the movie, never per episode.
{ intent: 'posterTile', type: 'poster', orient: 'P' },
// 16:9; a real production still for two thirds, season or show artwork for the rest. The app
// picks the landscape image on `type` alone, so dropping this one hides it there silently.
{ intent: 'episodeStill', type: 'still', orient: 'L' },
// A transparent wordmark, which is none of the DTD's five types, so `system` is all it has.
{ intent: 'titleTreatment', orient: 'L' },
]
function parseIcon(item) {
return imageUrl(item, 'posterTile')
}
function imageUrl(item, intent) {
return `${API_IMAGE_ENDPOINT}/intent/${item.id}/${intent}`
}
// <icon> repeats the poster because the two elements are read by different clients: <icon> has only
// a src, while <image> is the one that can say what the picture is.
function parseImage(item) {
return IMAGE_INTENTS.map(({ intent, type, orient }) => ({
...(type ? { type } : {}),
orient,
system: intent,
value: imageUrl(item, intent),
}))
} }
@@ -1,4 +1,4 @@
// https://github.com/iptv-org/epg/blob/e4f92bb2a2768dcba3dbbd52b19d78d96bebc31e/sites/web.magentatv.de/web.magentatv.de.config.js //https://github.com/iptv-org/epg/blob/master/sites/web.magentatv.de/web.magentatv.de.config.js
const axios = require('axios') const axios = require('axios')
const dayjs = require('dayjs') const dayjs = require('dayjs')
@@ -48,6 +48,7 @@ module.exports = {
title: item.name, title: item.name,
description: item.introduce, description: item.introduce,
image: parseImage(item), image: parseImage(item),
icon: parseImage(item),
category: parseCategory(item), category: parseCategory(item),
start: parseStart(item), start: parseStart(item),
stop: parseStop(item), stop: parseStop(item),
@@ -178,7 +179,7 @@ async function fetchCookieAndToken() {
T: 'Windows_chrome_118' T: 'Windows_chrome_118'
}, },
method: 'POST', method: 'POST',
data: '{"terminalid":"00:00:00:00:00:00","mac":"00:00:00:00:00:00","terminaltype":"WEBTV","utcEnable":1,"timezone":"Etc/GMT0","userType":3,"terminalvendor":"Unknown"}', data: '{"terminalid":"00:00:00:00:00:00","mac":"00:00:00:00:00:00","terminaltype":"WEBTV","utcEnable":1,"timezone":"Etc/GMT0","userType":3,"terminalvendor":"Unknown"}'
}) })
// Extract the cookies specified in cookiesToExtract // Extract the cookies specified in cookiesToExtract
@@ -202,8 +203,7 @@ async function fetchCookieAndToken() {
X_CSRFTOKEN = response.data.csrfToken X_CSRFTOKEN = response.data.csrfToken
Cookie = extractedCookies.join(' ') Cookie = extractedCookies.join(' ')
} catch (error) {
} catch(error) {
console.error(error) console.error(error)
} }
} }