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,46 +1,46 @@
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
module.exports = {
site: 'ipko.com',
days: 2,
url: function ({ date }) {
return `https://www.ipko.com/epg/admin/programs.php?date=${date.format('YYYY-MM-DD')}`
},
parser: function ({ content, channel, date }) {
let programs = []
const items = parseItems(content, channel)
items.forEach(item => {
const start = parseStart(item, date)
const stop = start.add(item.duration / 3, 'm')
programs.push({
title: item.program_name,
description: item.description,
category: item.category,
start: start.toString(),
stop: stop.toString()
})
})
return programs
}
}
function parseStart(item, date) {
const time = `${date.format('YYYY-MM-DD')} ${item.date}`
return dayjs.utc(time, 'YYYY-MM-DD HH:mm:ss')
}
function parseItems(content, channel) {
const data = JSON.parse(content)
const arr = Object.values(data.element)
const items = arr.find(el => {
return el[0] && el[0].channel_id == channel.site_id
})
return Array.isArray(items) ? items : []
}
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
module.exports = {
site: 'ipko.com',
days: 2,
url: function ({ date }) {
return `https://www.ipko.com/epg/admin/programs.php?date=${date.format('YYYY-MM-DD')}`
},
parser: function ({ content, channel, date }) {
let programs = []
const items = parseItems(content, channel)
items.forEach(item => {
const start = parseStart(item, date)
const stop = start.add(item.duration / 3, 'm')
programs.push({
title: item.program_name,
description: item.description,
category: item.category,
start: start.toString(),
stop: stop.toString()
})
})
return programs
}
}
function parseStart(item, date) {
const time = `${date.format('YYYY-MM-DD')} ${item.date}`
return dayjs.utc(time, 'YYYY-MM-DD HH:mm:ss')
}
function parseItems(content, channel) {
const data = JSON.parse(content)
const arr = Object.values(data.element)
const items = arr.find(el => {
return el[0] && el[0].channel_id == channel.site_id
})
return Array.isArray(items) ? items : []
}

View File

@@ -1,40 +1,40 @@
// npm run grab -- --site=ipko.com
const { parser, url } = require('./ipko.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-10-24', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '406',
xmltv_id: 'RTK1.xk'
}
const content =
'{"element":{"1":[{"id":6367,"channel_id":406,"program_name":"Beautiful People 13","name_short":"","description":"Lin largohet nga Nju Meksiko për t\'u vendosur në Nju Jork e për t\'ia nisur nga fillimi: një punë të re, shtëpi të re dhe njohje të reja. Bashkë me të janë vajzat e saj, Sofia, një 16 vjeçare që shkëlqen në shkollë, dhe Kareni, 20 vjeçare, që do të bë","category":"Sezoni I","duration":150,"day":"Sun","left_distanc":165,"date":"00:55:00"}]}}'
it('can generate valid url', () => {
const result = url({ date })
expect(result).toBe('https://www.ipko.com/epg/admin/programs.php?date=2021-10-24')
})
it('can parse response', () => {
const result = parser({ date, channel, content })
expect(result).toMatchObject([
{
start: 'Sun, 24 Oct 2021 00:55:00 GMT',
stop: 'Sun, 24 Oct 2021 01:45:00 GMT',
title: 'Beautiful People 13',
description:
"Lin largohet nga Nju Meksiko për t'u vendosur në Nju Jork e për t'ia nisur nga fillimi: një punë të re, shtëpi të re dhe njohje të reja. Bashkë me të janë vajzat e saj, Sofia, një 16 vjeçare që shkëlqen në shkollë, dhe Kareni, 20 vjeçare, që do të bë",
category: 'Sezoni I'
}
])
})
it('can handle empty guide', () => {
const result = parser({ date, channel, content: '{"element":{"1":[{"no":"no"}]}}' })
expect(result).toMatchObject([])
})
// npm run grab -- --site=ipko.com
const { parser, url } = require('./ipko.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-10-24', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '406',
xmltv_id: 'RTK1.xk'
}
const content =
'{"element":{"1":[{"id":6367,"channel_id":406,"program_name":"Beautiful People 13","name_short":"","description":"Lin largohet nga Nju Meksiko për t\'u vendosur në Nju Jork e për t\'ia nisur nga fillimi: një punë të re, shtëpi të re dhe njohje të reja. Bashkë me të janë vajzat e saj, Sofia, një 16 vjeçare që shkëlqen në shkollë, dhe Kareni, 20 vjeçare, që do të bë","category":"Sezoni I","duration":150,"day":"Sun","left_distanc":165,"date":"00:55:00"}]}}'
it('can generate valid url', () => {
const result = url({ date })
expect(result).toBe('https://www.ipko.com/epg/admin/programs.php?date=2021-10-24')
})
it('can parse response', () => {
const result = parser({ date, channel, content })
expect(result).toMatchObject([
{
start: 'Sun, 24 Oct 2021 00:55:00 GMT',
stop: 'Sun, 24 Oct 2021 01:45:00 GMT',
title: 'Beautiful People 13',
description:
"Lin largohet nga Nju Meksiko për t'u vendosur në Nju Jork e për t'ia nisur nga fillimi: një punë të re, shtëpi të re dhe njohje të reja. Bashkë me të janë vajzat e saj, Sofia, një 16 vjeçare që shkëlqen në shkollë, dhe Kareni, 20 vjeçare, që do të bë",
category: 'Sezoni I'
}
])
})
it('can handle empty guide', () => {
const result = parser({ date, channel, content: '{"element":{"1":[{"no":"no"}]}}' })
expect(result).toMatchObject([])
})