Skip to content

Commit 7f68498

Browse files
Merge pull request #2673 from iptv-org/update-pickx.be
Update pickx.be
2 parents 6b45cd9 + 6ee4986 commit 7f68498

10 files changed

+1588
-523
lines changed

sites/pickx.be/__data__/hash.html

Lines changed: 1114 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"21738594888692v.4.2"}

sites/pickx.be/pickx.be.channels.xml

Lines changed: 407 additions & 0 deletions
Large diffs are not rendered by default.

sites/pickx.be/pickx.be.config.js

Lines changed: 30 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
const axios = require('axios')
22
const dayjs = require('dayjs')
3-
const utc = require('dayjs/plugin/utc')
43

54
let apiVersion
65

7-
dayjs.extend(utc)
8-
96
module.exports = {
107
site: 'pickx.be',
118
days: 2,
12-
setApiVersion: function (version) {
13-
apiVersion = version
14-
},
15-
getApiVersion: function () {
16-
return apiVersion
17-
},
18-
fetchApiVersion: fetchApiVersion,
19-
url: async function ({ channel, date }) {
9+
async url({ channel, date }) {
2010
if (!apiVersion) {
2111
await fetchApiVersion()
2212
}
13+
2314
return `https://px-epg.azureedge.net/airings/${apiVersion}/${date.format(
2415
'YYYY-MM-DD'
2516
)}/channel/${channel.site_id}?timezone=Europe%2FBrussels`
@@ -49,90 +40,58 @@ module.exports = {
4940
episode: item.program.episodeNumber,
5041
actors: item.program.actors,
5142
director: item.program.director ? [item.program.director] : null,
52-
start: dayjs.utc(item.programScheduleStart),
53-
stop: dayjs.utc(item.programScheduleEnd)
43+
start: dayjs(item.programScheduleStart),
44+
stop: dayjs(item.programScheduleEnd)
5445
})
5546
})
5647
}
5748

5849
return programs
5950
},
60-
async channels({ lang = '' }) {
51+
async channels() {
52+
let channels = []
53+
6154
const query = {
6255
operationName: 'getChannels',
6356
variables: {
64-
language: lang,
57+
language: 'fr',
6558
queryParams: {},
6659
id: '0',
6760
params: {
6861
shouldReadFromCache: true
6962
}
7063
},
7164
query: `query getChannels($language: String!, $queryParams: ChannelQueryParams, $id: String, $params: ChannelParams) {
72-
channels(language: $language, queryParams: $queryParams, id: $id, params: $params) {
73-
id
74-
channelReferenceNumber
75-
name
76-
callLetter
77-
number
78-
logo {
79-
key
80-
url
81-
__typename
82-
}
83-
language
84-
hd
85-
radio
86-
replayable
87-
ottReplayable
88-
playable
89-
ottPlayable
90-
recordable
91-
subscribed
92-
cloudRecordable
93-
catchUpWindowInHours
94-
isOttNPVREnabled
95-
ottNPVRStart
96-
subscription {
97-
channelRef
98-
subscribed
99-
upselling {
100-
upsellable
101-
packages
102-
__typename
103-
}
104-
__typename
105-
}
106-
packages
107-
__typename
108-
}
109-
}`
65+
channels(language: $language, queryParams: $queryParams, id: $id, params: $params) {
66+
id
67+
name
68+
language
69+
radio
70+
}
71+
}`
11072
}
111-
const result = await axios
73+
74+
const data = await axios
11275
.post('https://api.proximusmwc.be/tiams/v3/graphql', query)
11376
.then(r => r.data)
11477
.catch(console.error)
11578

116-
return (
117-
result?.data?.channels
118-
.filter(
119-
channel =>
120-
!channel.radio && (!lang || channel.language === (lang === 'de' ? 'ger' : lang))
121-
)
122-
.map(channel => {
123-
return {
124-
lang: channel.language === 'ger' ? 'de' : channel.language,
125-
site_id: channel.id,
126-
name: channel.name
127-
}
128-
}) || []
129-
)
79+
data.data.channels.forEach(channel => {
80+
let lang = channel.language || 'fr'
81+
if (channel.language === 'ger') lang = 'de'
82+
83+
channels.push({
84+
lang,
85+
site_id: channel.id,
86+
name: channel.name
87+
})
88+
})
89+
90+
return channels
13091
}
13192
}
93+
13294
async function fetchApiVersion() {
133-
// you'll never find what happened here :)
134-
// load the pickx page and get the hash from the MWC configuration.
135-
// it's not the best way to get the version but it's the only way to get it.
13695
const hashUrl = 'https://www.pickx.be/nl/televisie/tv-gids'
13796
const hashData = await axios
13897
.get(hashUrl)

sites/pickx.be/pickx.be.test.js

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,49 @@
1-
jest.mock('./pickx.be.config.js', () => {
2-
const originalModule = jest.requireActual('./pickx.be.config.js')
3-
return {
4-
...originalModule,
5-
fetchApiVersion: jest.fn(() => Promise.resolve())
6-
}
7-
})
8-
9-
const { parser, url, request, setApiVersion } = require('./pickx.be.config.js')
10-
1+
const { parser, url, request } = require('./pickx.be.config.js')
2+
const axios = require('axios')
113
const fs = require('fs')
124
const path = require('path')
135
const dayjs = require('dayjs')
146
const utc = require('dayjs/plugin/utc')
15-
167
dayjs.extend(utc)
178

9+
jest.mock('axios')
10+
11+
axios.get.mockImplementation((url, data) => {
12+
if (url === 'https://www.pickx.be/nl/televisie/tv-gids') {
13+
return Promise.resolve({
14+
data: fs.readFileSync(path.resolve(__dirname, '__data__/hash.html'), 'utf8')
15+
})
16+
} else if (
17+
url ===
18+
'https://www.pickx.be/api/s-375ce5e452cf964b4158545d9ddf26cc97d6411f0998a2fa7ed5922c88d5bdc4' &&
19+
JSON.stringify(data) ===
20+
JSON.stringify({
21+
headers: {
22+
Origin: 'https://www.pickx.be',
23+
Referer: 'https://www.pickx.be/'
24+
}
25+
})
26+
) {
27+
return Promise.resolve({
28+
status: 200,
29+
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/version.json')))
30+
})
31+
} else {
32+
return Promise.resolve({
33+
data: ''
34+
})
35+
}
36+
})
37+
1838
const date = dayjs.utc('2023-12-13').startOf('d')
1939
const channel = {
2040
lang: 'fr',
21-
site_id: 'UID0118',
22-
xmltv_id: 'Vedia.be'
41+
site_id: 'UID0118'
2342
}
2443

25-
beforeEach(() => {
26-
setApiVersion('mockedApiVersion')
27-
})
28-
2944
it('can generate valid url', async () => {
30-
const generatedUrl = await url({ channel, date })
31-
expect(generatedUrl).toBe(
32-
'https://px-epg.azureedge.net/airings/mockedApiVersion/2023-12-13/channel/UID0118?timezone=Europe%2FBrussels'
45+
expect(await url({ channel, date })).toBe(
46+
'https://px-epg.azureedge.net/airings/21738594888692v.4.2/2023-12-13/channel/UID0118?timezone=Europe%2FBrussels'
3347
)
3448
})
3549

sites/pickx.be/pickx.be_de.channels.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

sites/pickx.be/pickx.be_en.channels.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)