mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Create proximusmwc.be.config.js
This commit is contained in:
parent
ec57059055
commit
9a42474d3a
1 changed files with 78 additions and 0 deletions
78
sites/proximusmwc.be/proximusmwc.be.config.js
Normal file
78
sites/proximusmwc.be/proximusmwc.be.config.js
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
const axios = require('axios')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'proximusmwc.be',
|
||||||
|
url: 'https://api.proximusmwc.be/v2/graphql',
|
||||||
|
request: {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
data({ channel, date }) {
|
||||||
|
return {
|
||||||
|
query:
|
||||||
|
'query ($language: String!, $startTime: Int!, $endTime: Int!, $options: SchedulesByIntervalOptions) { schedulesByInterval(language: $language, startTime: $startTime, endTime: $endTime, options: $options) { trailId programReferenceNumber channelId title category startTime endTime image { key url __typename } parentalRating detailUrl grouped description shortDescription category categoryId subCategory links { episodeNumber id seasonId seasonName seriesId seriesTitle title type __typename } seriesId __typename }}',
|
||||||
|
variables: {
|
||||||
|
startTime: date.unix(),
|
||||||
|
endTime: date.add(1, 'd').unix(),
|
||||||
|
language: 'fr',
|
||||||
|
options: { channelIds: [channel.site_id] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parser: function ({ content, date, channel }) {
|
||||||
|
const programs = []
|
||||||
|
const items = parseItems(content)
|
||||||
|
items.forEach(item => {
|
||||||
|
programs.push({
|
||||||
|
title: item.title,
|
||||||
|
description: item.description,
|
||||||
|
icon: parseIcon(item),
|
||||||
|
category: parseCategory(item),
|
||||||
|
start: dayjs.unix(item.startTime),
|
||||||
|
stop: dayjs.unix(item.endTime)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
},
|
||||||
|
async channels() {
|
||||||
|
const query = {
|
||||||
|
operationName: 'getPlayableChannels',
|
||||||
|
variables: { language: 'fr', id: '0' },
|
||||||
|
query:
|
||||||
|
'query getPlayableChannels($language: String!, $queryParams: ChannelQueryParams, $id: String) { playableChannels(language: $language, queryParams: $queryParams, id: $id) { id name language }}'
|
||||||
|
}
|
||||||
|
const data = await axios
|
||||||
|
.post(`https://api.proximusmwc.be/v2/graphql`, query)
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.log)
|
||||||
|
|
||||||
|
const channels = []
|
||||||
|
for (let item of data.data.playableChannels) {
|
||||||
|
channels.push({
|
||||||
|
lang: item.language,
|
||||||
|
site_id: item.id,
|
||||||
|
name: item.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return channels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseCategory(item) {
|
||||||
|
return item.category ? item.category.replace(/^C\./, '') : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseIcon(item) {
|
||||||
|
return item.image[0] ? item.image[0].url : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
if (!data || !data.data || !Array.isArray(data.data.schedulesByInterval)) return []
|
||||||
|
|
||||||
|
return data.data.schedulesByInterval
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue