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,56 +1,56 @@
|
|||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'siba.com.co',
|
||||
days: 2,
|
||||
url: 'http://devportal.siba.com.co/index.php?action=grilla',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
},
|
||||
data({ channel, date }) {
|
||||
const params = new URLSearchParams()
|
||||
params.append('servicio', '10')
|
||||
params.append('ini', date.unix())
|
||||
params.append('end', date.add(1, 'd').unix())
|
||||
params.append('chn', channel.site_id)
|
||||
|
||||
return params
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.nom,
|
||||
start: parseStart(item).toJSON(),
|
||||
stop: parseStop(item).toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.ini)
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.unix(item.fin)
|
||||
}
|
||||
|
||||
function parseContent(content, channel) {
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.list)) return null
|
||||
|
||||
return data.list.find(i => i.id === channel.site_id)
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = parseContent(content, channel)
|
||||
|
||||
return data ? data.prog : []
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'siba.com.co',
|
||||
days: 2,
|
||||
url: 'http://devportal.siba.com.co/index.php?action=grilla',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
},
|
||||
data({ channel, date }) {
|
||||
const params = new URLSearchParams()
|
||||
params.append('servicio', '10')
|
||||
params.append('ini', date.unix())
|
||||
params.append('end', date.add(1, 'd').unix())
|
||||
params.append('chn', channel.site_id)
|
||||
|
||||
return params
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.nom,
|
||||
start: parseStart(item).toJSON(),
|
||||
stop: parseStop(item).toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.ini)
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.unix(item.fin)
|
||||
}
|
||||
|
||||
function parseContent(content, channel) {
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.list)) return null
|
||||
|
||||
return data.list.find(i => i.id === channel.site_id)
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = parseContent(content, channel)
|
||||
|
||||
return data ? data.prog : []
|
||||
}
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
// npm run grab -- --site=siba.com.co
|
||||
|
||||
const { parser, url, request } = require('./siba.com.co.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-11', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '395',
|
||||
xmltv_id: 'CanalClaro.cl'
|
||||
}
|
||||
const content =
|
||||
'{"list":[{"id":"395","nom":"CANAL CLARO","num":"102","logo":"7c4b9e8566a6e867d1db4c7ce845f1f4.jpg","cat":"Exclusivos Claro","prog":[{"id":"665724465","nom":"Worst Cooks In America","ini":1636588800,"fin":1636592400}]}],"error":null}'
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('http://devportal.siba.com.co/index.php?action=grilla')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
expect(request.headers).toMatchObject({
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
const result = request.data({ channel, date })
|
||||
expect(result.has('servicio')).toBe(true)
|
||||
expect(result.has('ini')).toBe(true)
|
||||
expect(result.has('end')).toBe(true)
|
||||
expect(result.has('chn')).toBe(true)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-11T00:00:00.000Z',
|
||||
stop: '2021-11-11T01:00:00.000Z',
|
||||
title: 'Worst Cooks In America'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: '{"list":[],"error":null}'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run grab -- --site=siba.com.co
|
||||
|
||||
const { parser, url, request } = require('./siba.com.co.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-11', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '395',
|
||||
xmltv_id: 'CanalClaro.cl'
|
||||
}
|
||||
const content =
|
||||
'{"list":[{"id":"395","nom":"CANAL CLARO","num":"102","logo":"7c4b9e8566a6e867d1db4c7ce845f1f4.jpg","cat":"Exclusivos Claro","prog":[{"id":"665724465","nom":"Worst Cooks In America","ini":1636588800,"fin":1636592400}]}],"error":null}'
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('http://devportal.siba.com.co/index.php?action=grilla')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
expect(request.headers).toMatchObject({
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
const result = request.data({ channel, date })
|
||||
expect(result.has('servicio')).toBe(true)
|
||||
expect(result.has('ini')).toBe(true)
|
||||
expect(result.has('end')).toBe(true)
|
||||
expect(result.has('chn')).toBe(true)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-11T00:00:00.000Z',
|
||||
stop: '2021-11-11T01:00:00.000Z',
|
||||
title: 'Worst Cooks In America'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: '{"list":[],"error":null}'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue