Fixes linter errors

This commit is contained in:
freearhey 2023-10-15 14:08:23 +03:00
parent 57e508fc3b
commit 63c86a2b30
393 changed files with 28447 additions and 28443 deletions

View file

@ -1,50 +1,50 @@
const axios = require('axios')
const dayjs = require('dayjs')
module.exports = {
site: 'tvarenasport.com',
days: 2,
url: function ({ date }) {
return `https://www.tvarenasport.com/api/schedule?date=${date.format('DD-MM-YYYY')}`
},
parser: function ({ content, channel }) {
let programs = []
const items = parseItems(content, channel)
items.forEach(item => {
programs.push({
title: item.title.trim(),
category: item.league,
description: item.sport.trim(),
start: dayjs(item.start),
stop: dayjs(item.end)
})
})
return programs
},
async channels() {
const data = await axios
.get('https://www.tvarenasport.com/api/schedule')
.then(r => r.data)
.catch(console.log)
const channels = []
for (let id in data.channels) {
const item = data.channels[id]
channels.push({
lang: 'sr',
site_id: id,
name: item.name
})
}
return channels
}
}
function parseItems(content, channel) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.items)) return []
return data.items.filter(i => i.group === channel.site_id)
}
const axios = require('axios')
const dayjs = require('dayjs')
module.exports = {
site: 'tvarenasport.com',
days: 2,
url: function ({ date }) {
return `https://www.tvarenasport.com/api/schedule?date=${date.format('DD-MM-YYYY')}`
},
parser: function ({ content, channel }) {
let programs = []
const items = parseItems(content, channel)
items.forEach(item => {
programs.push({
title: item.title.trim(),
category: item.league,
description: item.sport.trim(),
start: dayjs(item.start),
stop: dayjs(item.end)
})
})
return programs
},
async channels() {
const data = await axios
.get('https://www.tvarenasport.com/api/schedule')
.then(r => r.data)
.catch(console.log)
const channels = []
for (let id in data.channels) {
const item = data.channels[id]
channels.push({
lang: 'sr',
site_id: id,
name: item.name
})
}
return channels
}
}
function parseItems(content, channel) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.items)) return []
return data.items.filter(i => i.group === channel.site_id)
}

View file

@ -1,48 +1,48 @@
// npm run channels:parse -- --config=./sites/tvarenasport.com/tvarenasport.com.config.js --output=./sites/tvarenasport.com/tvarenasport.com.channels.xml --set=country:rs
// npm run grab -- --site=tvarenasport.com
const { parser, url } = require('./tvarenasport.com.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-17', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '380',
xmltv_id: 'ArenaSport1.rs'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe('https://www.tvarenasport.com/api/schedule?date=17-11-2021')
})
it('can parse response', () => {
const content =
'{"items":[{"id":2857,"title":"Crvena zvezda mts - Partizan NIS","start":"2021-11-16T23:30:00Z","end":"2021-11-17T01:30:00Z","sport":"ABA LIGA","league":"Ko\u0161arka","group":"380","isLive":false,"doNotMiss":false,"domain":"srb"},{"id":3155,"title":"Sao Paulo - Flamengo","start":"2021-11-17T00:00:00Z","end":"2021-11-17T02:00:00Z","sport":"BRAZILSKA LIGA","league":"Fudbal","group":"381","isLive":false,"doNotMiss":false,"domain":"srb"}]}'
const result = parser({ channel, content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2021-11-16T23:30:00.000Z',
stop: '2021-11-17T01:30:00.000Z',
title: 'Crvena zvezda mts - Partizan NIS',
category: 'Ko\u0161arka',
description: 'ABA LIGA'
}
])
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: '{"channels":[]}'
})
expect(result).toMatchObject([])
})
// npm run channels:parse -- --config=./sites/tvarenasport.com/tvarenasport.com.config.js --output=./sites/tvarenasport.com/tvarenasport.com.channels.xml --set=country:rs
// npm run grab -- --site=tvarenasport.com
const { parser, url } = require('./tvarenasport.com.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-17', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '380',
xmltv_id: 'ArenaSport1.rs'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe('https://www.tvarenasport.com/api/schedule?date=17-11-2021')
})
it('can parse response', () => {
const content =
'{"items":[{"id":2857,"title":"Crvena zvezda mts - Partizan NIS","start":"2021-11-16T23:30:00Z","end":"2021-11-17T01:30:00Z","sport":"ABA LIGA","league":"Ko\u0161arka","group":"380","isLive":false,"doNotMiss":false,"domain":"srb"},{"id":3155,"title":"Sao Paulo - Flamengo","start":"2021-11-17T00:00:00Z","end":"2021-11-17T02:00:00Z","sport":"BRAZILSKA LIGA","league":"Fudbal","group":"381","isLive":false,"doNotMiss":false,"domain":"srb"}]}'
const result = parser({ channel, content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2021-11-16T23:30:00.000Z',
stop: '2021-11-17T01:30:00.000Z',
title: 'Crvena zvezda mts - Partizan NIS',
category: 'Ko\u0161arka',
description: 'ABA LIGA'
}
])
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: '{"channels":[]}'
})
expect(result).toMatchObject([])
})