Fix linter issues in sites/

This commit is contained in:
freearhey 2025-01-01 12:27:22 +03:00
parent d6d20b6413
commit 5df982bb7c
129 changed files with 3316 additions and 3226 deletions

View file

@ -26,22 +26,25 @@ module.exports = {
if (content) {
const dates = []
const $ = cheerio.load(content)
const parent = $(`.tv-scheme-chanel-header img[src*="chanel-${channel.site_id}.png"]`)
.parents('div')
const parent = $(
`.tv-scheme-chanel-header img[src*="chanel-${channel.site_id}.png"]`
).parents('div')
parent
.siblings('.tv-scheme-days')
.find('a').toArray()
.forEach(el => {
const a = $(el)
const dt = a.find('span:nth-child(3)').text()
dates.push(dayjs(dt + date.year(), 'DD.MM.YYYY'))
})
.find('a')
.toArray()
.forEach(el => {
const a = $(el)
const dt = a.find('span:nth-child(3)').text()
dates.push(dayjs(dt + date.year(), 'DD.MM.YYYY'))
})
parent
.siblings('.tv-scheme-new-slider-wrapper')
.find('.tv-scheme-new-slider-item').toArray()
.forEach((el, i) => {
programs.push(...parseSchedules($(el), dates[i], module.exports.tz))
})
.find('.tv-scheme-new-slider-item')
.toArray()
.forEach((el, i) => {
programs.push(...parseSchedules($(el), dates[i], module.exports.tz))
})
programs.forEach((s, i) => {
if (i < programs.length - 2) {
s.stop = programs[i + 1].start
@ -51,8 +54,11 @@ module.exports = {
})
}
return programs
.filter(p => p.start.format('YYYY-MM-DD') === expectedDate || p.stop.format('YYYY-MM-DD') === expectedDate)
return programs.filter(
p =>
p.start.format('YYYY-MM-DD') === expectedDate ||
p.stop.format('YYYY-MM-DD') === expectedDate
)
},
async channels() {
const channels = []
@ -81,7 +87,9 @@ module.exports = {
const $ = cheerio.load(data)
const items = $('.tv-scheme-chanel-header img').toArray()
for (const item of items) {
const [, id] = $(item).attr('src').match(/chanel-([a-z0-9]+)\.png/) || [null, null]
const [, id] = $(item)
.attr('src')
.match(/chanel-([a-z0-9]+)\.png/) || [null, null]
if (id) {
channels.push({
lang: this.lang,
@ -99,7 +107,8 @@ module.exports = {
function parseSchedules($s, date, tz) {
const schedules = []
const $ = $s._make
$s.find('.slider-content').toArray()
$s.find('.slider-content')
.toArray()
.forEach(el => {
schedules.push(parseSchedule($(el), date, tz))
})

View file

@ -32,12 +32,12 @@ it('can parse response', () => {
stop: '2024-12-07T05:00:00.000Z',
title: 'EVROPSKO PRVENSTVO Ž',
description: 'Francuska - Crna Gora',
category: 'Rukomet',
category: 'Rukomet'
})
expect(result[8]).toMatchObject({
start: '2024-12-07T11:00:00.000Z',
stop: '2024-12-07T11:05:00.000Z',
title: 'Arena News',
title: 'Arena News'
})
})