mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
code refractoring + fix tests
This commit is contained in:
parent
51244812c5
commit
0b74e95558
2 changed files with 8 additions and 8 deletions
|
@ -63,7 +63,7 @@ module.exports = {
|
|||
const detail = await loadProgramDetails(item, channel)
|
||||
programs.push({
|
||||
title: item.title,
|
||||
icon: detail.icon,
|
||||
icon: parseIcon(item),
|
||||
description: detail.longDescription,
|
||||
category: detail.genres,
|
||||
actors: detail.actors,
|
||||
|
@ -94,15 +94,10 @@ module.exports = {
|
|||
|
||||
async function loadProgramDetails(item, channel) {
|
||||
if (!item.id) return {}
|
||||
const url = `${API_PROD_ENDPOINT}/replayEvent/${item.id}?returnLinearContent=true&language=${channel.lang}`
|
||||
const url = `${API_PROD_ENDPOINT}/replayEvent/${item.id}?returnLinearContent=true&language=${channel.lang}`
|
||||
const data = await axios
|
||||
.get(url)
|
||||
.then(r => {
|
||||
var icon = `${API_IMAGE_ENDPOINT}/intent/${item.id}/posterTile`;
|
||||
|
||||
return { icon: icon, ...r.data };
|
||||
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data || {}
|
||||
|
@ -137,3 +132,7 @@ function parseEpisode(detail) {
|
|||
if (String(detail.episodeNumber).length > 3) return null
|
||||
return detail.episodeNumber
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return `${API_IMAGE_ENDPOINT}/intent/${item.id}/posterTile`;
|
||||
}
|
|
@ -63,6 +63,7 @@ it('can parse response', async () => {
|
|||
start: '2022-10-29T23:56:00.000Z',
|
||||
stop: '2022-10-30T01:44:00.000Z',
|
||||
title: 'Queer as Folk USA',
|
||||
icon: 'https://staticqbr-prod-be.gnp.cloud.telenet.tv/image-service/intent/crid:~~2F~~2Fgn.tv~~2F2459095~~2FEP036477800004,imi:0a2f4207b03c16c70b7fb3be8e07881aafe44106/posterTile',
|
||||
description:
|
||||
"Justin belandt in de gevangenis, Brian en Brandon banen zich een weg door de lijst, Ben treurt, Melanie en Lindsay proberen een interne scheiding en Emmett's stalker onthult zichzelf.",
|
||||
category: ['Dramaserie', 'LHBTI'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue