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,50 +1,50 @@
|
|||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'sky.de',
|
||||
days: 2,
|
||||
url: 'https://www.sky.de/sgtvg/service/getBroadcastsForGrid',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'accept-language': 'en-GB',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
accept: 'application/json'
|
||||
},
|
||||
data: function ({ channel, date }) {
|
||||
return {
|
||||
cil: [channel.site_id],
|
||||
d: date.valueOf()
|
||||
}
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
const programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.et,
|
||||
description: item.epit,
|
||||
category: item.ec,
|
||||
start: dayjs(item.bsdt),
|
||||
stop: dayjs(item.bedt),
|
||||
season: item.sn,
|
||||
episode: item.en,
|
||||
icon: item.pu ? `http://sky.de${item.pu}` : null
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseContent(content, channel) {
|
||||
const json = JSON.parse(content)
|
||||
if (!Array.isArray(json.cl)) return null
|
||||
return json.cl.find(i => i.ci == channel.site_id)
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = parseContent(content, channel)
|
||||
return data && Array.isArray(data.el) ? data.el : []
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'sky.de',
|
||||
days: 2,
|
||||
url: 'https://www.sky.de/sgtvg/service/getBroadcastsForGrid',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'accept-language': 'en-GB',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
accept: 'application/json'
|
||||
},
|
||||
data: function ({ channel, date }) {
|
||||
return {
|
||||
cil: [channel.site_id],
|
||||
d: date.valueOf()
|
||||
}
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
const programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.et,
|
||||
description: item.epit,
|
||||
category: item.ec,
|
||||
start: dayjs(item.bsdt),
|
||||
stop: dayjs(item.bedt),
|
||||
season: item.sn,
|
||||
episode: item.en,
|
||||
icon: item.pu ? `http://sky.de${item.pu}` : null
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseContent(content, channel) {
|
||||
const json = JSON.parse(content)
|
||||
if (!Array.isArray(json.cl)) return null
|
||||
return json.cl.find(i => i.ci == channel.site_id)
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = parseContent(content, channel)
|
||||
return data && Array.isArray(data.el) ? data.el : []
|
||||
}
|
||||
|
|
|
@ -1,68 +1,68 @@
|
|||
// npm run grab -- --site=sky.de
|
||||
|
||||
const { parser, url, request } = require('./sky.de.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-02-28', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '522',
|
||||
xmltv_id: 'WarnerTVComedyHD.de'
|
||||
}
|
||||
|
||||
const content =
|
||||
'{"cl":[{"ci":522,"el":[{"ei":122309300,"bsdt":1645916700000,"bst":"00:05","bedt":1645918200000,"len":25,"et":"King of Queens","ec":"Comedyserie","cop":"USA","yop":2001,"fsk":"ab 0 Jahre","epit":"Der Experte","sn":"4","en":"11","pu":"/static/img/program_guide/1522936_s.jpg"},{"ei":122309301,"bsdt":1645918200000,"bst":"00:30","bedt":1645919700000,"len":25,"et":"King of Queens","ec":"Comedyserie","cop":"USA","yop":2001,"fsk":"ab 0 Jahre","epit":"Speedy Gonzales","sn":"4","en":"12","pu":"/static/img/program_guide/1522937_s.jpg"}]}]}'
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://www.sky.de/sgtvg/service/getBroadcastsForGrid')
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
cil: [channel.site_id],
|
||||
d: date.valueOf()
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: 'King of Queens',
|
||||
description: 'Der Experte',
|
||||
category: 'Comedyserie',
|
||||
start: '2022-02-26T23:05:00.000Z',
|
||||
stop: '2022-02-26T23:30:00.000Z',
|
||||
season: '4',
|
||||
episode: '11',
|
||||
icon: 'http://sky.de/static/img/program_guide/1522936_s.jpg'
|
||||
},
|
||||
{
|
||||
title: 'King of Queens',
|
||||
description: 'Speedy Gonzales',
|
||||
category: 'Comedyserie',
|
||||
start: '2022-02-26T23:30:00.000Z',
|
||||
stop: '2022-02-26T23:55:00.000Z',
|
||||
season: '4',
|
||||
episode: '12',
|
||||
icon: 'http://sky.de/static/img/program_guide/1522937_s.jpg'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '[]'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run grab -- --site=sky.de
|
||||
|
||||
const { parser, url, request } = require('./sky.de.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-02-28', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '522',
|
||||
xmltv_id: 'WarnerTVComedyHD.de'
|
||||
}
|
||||
|
||||
const content =
|
||||
'{"cl":[{"ci":522,"el":[{"ei":122309300,"bsdt":1645916700000,"bst":"00:05","bedt":1645918200000,"len":25,"et":"King of Queens","ec":"Comedyserie","cop":"USA","yop":2001,"fsk":"ab 0 Jahre","epit":"Der Experte","sn":"4","en":"11","pu":"/static/img/program_guide/1522936_s.jpg"},{"ei":122309301,"bsdt":1645918200000,"bst":"00:30","bedt":1645919700000,"len":25,"et":"King of Queens","ec":"Comedyserie","cop":"USA","yop":2001,"fsk":"ab 0 Jahre","epit":"Speedy Gonzales","sn":"4","en":"12","pu":"/static/img/program_guide/1522937_s.jpg"}]}]}'
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://www.sky.de/sgtvg/service/getBroadcastsForGrid')
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
cil: [channel.site_id],
|
||||
d: date.valueOf()
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: 'King of Queens',
|
||||
description: 'Der Experte',
|
||||
category: 'Comedyserie',
|
||||
start: '2022-02-26T23:05:00.000Z',
|
||||
stop: '2022-02-26T23:30:00.000Z',
|
||||
season: '4',
|
||||
episode: '11',
|
||||
icon: 'http://sky.de/static/img/program_guide/1522936_s.jpg'
|
||||
},
|
||||
{
|
||||
title: 'King of Queens',
|
||||
description: 'Speedy Gonzales',
|
||||
category: 'Comedyserie',
|
||||
start: '2022-02-26T23:30:00.000Z',
|
||||
stop: '2022-02-26T23:55:00.000Z',
|
||||
season: '4',
|
||||
episode: '12',
|
||||
icon: 'http://sky.de/static/img/program_guide/1522937_s.jpg'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '[]'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue