mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Fixes linter errors
This commit is contained in:
parent
57e508fc3b
commit
63c86a2b30
393 changed files with 28447 additions and 28443 deletions
|
@ -1,47 +1,47 @@
|
|||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'chaines-tv.orange.fr',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://rp-ott-mediation-tv.woopic.com/api-gw/live/v3/applications/STB4PC/programs?groupBy=channel&includeEmptyChannels=false&period=${date.valueOf()},${date
|
||||
.add(1, 'd')
|
||||
.valueOf()}&after=${channel.site_id}&limit=1`
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item)
|
||||
const stop = parseStop(item, start)
|
||||
programs.push({
|
||||
title: item.title,
|
||||
category: item.genreDetailed,
|
||||
description: item.synopsis,
|
||||
icon: parseIcon(item),
|
||||
start: start.toJSON(),
|
||||
stop: stop.toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.covers && item.covers.length ? item.covers[0].url : null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.diffusionDate)
|
||||
}
|
||||
|
||||
function parseStop(item, start) {
|
||||
return start.add(item.duration, 's')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return data && data[channel.site_id] ? data[channel.site_id] : []
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'chaines-tv.orange.fr',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://rp-ott-mediation-tv.woopic.com/api-gw/live/v3/applications/STB4PC/programs?groupBy=channel&includeEmptyChannels=false&period=${date.valueOf()},${date
|
||||
.add(1, 'd')
|
||||
.valueOf()}&after=${channel.site_id}&limit=1`
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item)
|
||||
const stop = parseStop(item, start)
|
||||
programs.push({
|
||||
title: item.title,
|
||||
category: item.genreDetailed,
|
||||
description: item.synopsis,
|
||||
icon: parseIcon(item),
|
||||
start: start.toJSON(),
|
||||
stop: stop.toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.covers && item.covers.length ? item.covers[0].url : null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.diffusionDate)
|
||||
}
|
||||
|
||||
function parseStop(item, start) {
|
||||
return start.add(item.duration, 's')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return data && data[channel.site_id] ? data[channel.site_id] : []
|
||||
}
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
// npm run grab -- --site=chaines-tv.orange.fr
|
||||
|
||||
const { parser, url } = require('./chaines-tv.orange.fr.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2021-11-08', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '192',
|
||||
xmltv_id: 'TF1.fr'
|
||||
}
|
||||
const content =
|
||||
'{"192":[{"id":1635062528017,"programType":"EPISODE","title":"Tête de liste","channelId":"192","channelZappingNumber":11,"covers":[{"format":"RATIO_16_9","url":"https://proxymedia.woopic.com/340/p/169_EMI_9697669.jpg"},{"format":"RATIO_4_3","url":"https://proxymedia.woopic.com/340/p/43_EMI_9697669.jpg"}],"diffusionDate":1636328100,"duration":2700,"csa":2,"synopsis":"Un tueur en série prend un plaisir pervers à prévenir les autorités de Tallahassee avant chaque nouveau meurtre. Rossi apprend le décès d\'un de ses vieux amis.","languageVersion":"VM","hearingImpaired":true,"audioDescription":false,"season":{"number":10,"episodesCount":23,"serie":{"title":"Esprits criminels"}},"episodeNumber":12,"definition":"SD","links":[{"rel":"SELF","href":"https://rp-live.orange.fr/live-webapp/v3/applications/STB4PC/programs/1635062528017"}],"dayPart":"OTHER","catchupId":null,"genre":"Série","genreDetailed":"Série Suspense"}]}'
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ channel, date })
|
||||
expect(result).toBe(
|
||||
'https://rp-ott-mediation-tv.woopic.com/api-gw/live/v3/applications/STB4PC/programs?groupBy=channel&includeEmptyChannels=false&period=1636329600000,1636416000000&after=192&limit=1'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-07T23:35:00.000Z',
|
||||
stop: '2021-11-08T00:20:00.000Z',
|
||||
title: 'Tête de liste',
|
||||
description:
|
||||
"Un tueur en série prend un plaisir pervers à prévenir les autorités de Tallahassee avant chaque nouveau meurtre. Rossi apprend le décès d'un de ses vieux amis.",
|
||||
category: 'Série Suspense',
|
||||
icon: 'https://proxymedia.woopic.com/340/p/169_EMI_9697669.jpg'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content:
|
||||
'{"code":60,"message":"Resource not found","param":{},"description":"L\'URI demandé ou la ressource demandée n\'existe pas.","stackTrace":null}'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run grab -- --site=chaines-tv.orange.fr
|
||||
|
||||
const { parser, url } = require('./chaines-tv.orange.fr.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2021-11-08', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '192',
|
||||
xmltv_id: 'TF1.fr'
|
||||
}
|
||||
const content =
|
||||
'{"192":[{"id":1635062528017,"programType":"EPISODE","title":"Tête de liste","channelId":"192","channelZappingNumber":11,"covers":[{"format":"RATIO_16_9","url":"https://proxymedia.woopic.com/340/p/169_EMI_9697669.jpg"},{"format":"RATIO_4_3","url":"https://proxymedia.woopic.com/340/p/43_EMI_9697669.jpg"}],"diffusionDate":1636328100,"duration":2700,"csa":2,"synopsis":"Un tueur en série prend un plaisir pervers à prévenir les autorités de Tallahassee avant chaque nouveau meurtre. Rossi apprend le décès d\'un de ses vieux amis.","languageVersion":"VM","hearingImpaired":true,"audioDescription":false,"season":{"number":10,"episodesCount":23,"serie":{"title":"Esprits criminels"}},"episodeNumber":12,"definition":"SD","links":[{"rel":"SELF","href":"https://rp-live.orange.fr/live-webapp/v3/applications/STB4PC/programs/1635062528017"}],"dayPart":"OTHER","catchupId":null,"genre":"Série","genreDetailed":"Série Suspense"}]}'
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ channel, date })
|
||||
expect(result).toBe(
|
||||
'https://rp-ott-mediation-tv.woopic.com/api-gw/live/v3/applications/STB4PC/programs?groupBy=channel&includeEmptyChannels=false&period=1636329600000,1636416000000&after=192&limit=1'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-07T23:35:00.000Z',
|
||||
stop: '2021-11-08T00:20:00.000Z',
|
||||
title: 'Tête de liste',
|
||||
description:
|
||||
"Un tueur en série prend un plaisir pervers à prévenir les autorités de Tallahassee avant chaque nouveau meurtre. Rossi apprend le décès d'un de ses vieux amis.",
|
||||
category: 'Série Suspense',
|
||||
icon: 'https://proxymedia.woopic.com/340/p/169_EMI_9697669.jpg'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content:
|
||||
'{"code":60,"message":"Resource not found","param":{},"description":"L\'URI demandé ou la ressource demandée n\'existe pas.","stackTrace":null}'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue