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

@@ -1,73 +1,80 @@
const axios = require('axios')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(customParseFormat)
module.exports = {
site: 'ipko.tv',
timezone: 'Europe/Belgrade',
days: 5,
url({ date, channel }) { return 'https://stargate.ipko.tv/api/titan.tv.WebEpg/GetWebEpgData' },
request: {
method: 'POST',
headers: {
'Host': 'stargate.ipko.tv',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0',
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'nl,en-US;q=0.7,en;q=0.3',
'Content-Type': 'application/json',
'X-AppLayout': '1',
'x-language': 'sq',
'Origin': 'https://ipko.tv',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'Sec-GPC': '1',
'Connection': 'keep-alive'
},
data({ channel, date }) {
const todayEpoch = date.startOf('day').unix();
const nextDayEpoch = date.add(1, 'day').startOf('day').unix();
return JSON.stringify({
ch_ext_id: channel.site_id,
from: todayEpoch,
to: nextDayEpoch
})
}
},
parser: function ({ content }) {
const programs = [];
const data = JSON.parse(content);
data.shows.forEach(show => {
const start = dayjs.unix(show.show_start).utc();
const stop = dayjs.unix(show.show_end).utc();
const programData = {
title: show.title,
description: show.summary || 'No description available',
start: start.toISOString(),
stop: stop.toISOString(),
thumbnail: show.thumbnail
}
programs.push(programData)
})
return programs
},
async channels() {
const response = await axios.post('https://stargate.ipko.tv/api/titan.tv.WebEpg/ZapList', JSON.stringify({ includeRadioStations: true }), {
headers: this.request.headers
});
const data = response.data.data;
return data.map(item => ({
lang: 'sq',
name: String(item.channel.title),
site_id: String(item.channel.id),
//logo: String(item.channel.logo)
}))
}
}
const axios = require('axios')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(customParseFormat)
module.exports = {
site: 'ipko.tv',
timezone: 'Europe/Belgrade',
days: 5,
url() {
return 'https://stargate.ipko.tv/api/titan.tv.WebEpg/GetWebEpgData'
},
request: {
method: 'POST',
headers: {
Host: 'stargate.ipko.tv',
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0',
Accept: 'application/json, text/plain, */*',
'Accept-Language': 'nl,en-US;q=0.7,en;q=0.3',
'Content-Type': 'application/json',
'X-AppLayout': '1',
'x-language': 'sq',
Origin: 'https://ipko.tv',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'Sec-GPC': '1',
Connection: 'keep-alive'
},
data({ channel, date }) {
const todayEpoch = date.startOf('day').unix()
const nextDayEpoch = date.add(1, 'day').startOf('day').unix()
return JSON.stringify({
ch_ext_id: channel.site_id,
from: todayEpoch,
to: nextDayEpoch
})
}
},
parser: function ({ content }) {
const programs = []
const data = JSON.parse(content)
data.shows.forEach(show => {
const start = dayjs.unix(show.show_start).utc()
const stop = dayjs.unix(show.show_end).utc()
const programData = {
title: show.title,
description: show.summary || 'No description available',
start: start.toISOString(),
stop: stop.toISOString(),
thumbnail: show.thumbnail
}
programs.push(programData)
})
return programs
},
async channels() {
const response = await axios.post(
'https://stargate.ipko.tv/api/titan.tv.WebEpg/ZapList',
JSON.stringify({ includeRadioStations: true }),
{
headers: this.request.headers
}
)
const data = response.data.data
return data.map(item => ({
lang: 'sq',
name: String(item.channel.title),
site_id: String(item.channel.id)
//logo: String(item.channel.logo)
}))
}
}

View File

@@ -1,115 +1,111 @@
const { parser, url } = require('./ipko.tv.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('2024-12-24', 'YYYY-MM-DD').startOf('day')
const channel = {
site_id: 'ipko-promo',
xmltv_id: 'IPKOPROMO'
}
it('can generate valid url', () => {
expect(url({ date, channel })).toBe('https://stargate.ipko.tv/api/titan.tv.WebEpg/GetWebEpgData')
})
it('can parse response', () => {
const content = `
{
"shows": [
{
"title": "IPKO Promo",
"show_start": 1735012800,
"show_end": 1735020000,
"timestamp": "5:00 - 7:00",
"show_id": "EPG_TvProfil_IPKOPROMO_296105567",
"thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg",
"is_adult": false,
"friendly_id": "ipko_promo_4cf3",
"pg": "",
"genres": [],
"year": 0,
"summary": "",
"categories": "Other",
"stb_only": false,
"is_live": false,
"original_title": "IPKO Promo"
},
{
"title": "IPKO Promo",
"show_start": 1735020000,
"show_end": 1735027200,
"timestamp": "7:00 - 9:00",
"show_id": "EPG_TvProfil_IPKOPROMO_296105568",
"thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg",
"is_adult": false,
"friendly_id": "ipko_promo_416b",
"pg": "",
"genres": [],
"year": 0,
"summary": "",
"categories": "Other",
"stb_only": false,
"is_live": false,
"original_title": "IPKO Promo"
},
{
"title": "IPKO Promo",
"show_start": 1735027200,
"show_end": 1735034400,
"timestamp": "9:00 - 11:00",
"show_id": "EPG_TvProfil_IPKOPROMO_296105569",
"thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg",
"is_adult": false,
"friendly_id": "ipko_promo_2e23",
"pg": "",
"genres": [],
"year": 0,
"summary": "",
"categories": "Other",
"stb_only": false,
"is_live": false,
"original_title": "IPKO Promo"
}
]
}`
const result = parser({ content, channel }).map(p => {
p.start = p.start
p.stop = p.stop
return p
})
expect(result).toMatchObject([
{
title: "IPKO Promo",
description: "No description available",
start: "2024-12-24T04:00:00.000Z",
stop: "2024-12-24T06:00:00.000Z",
thumbnail: "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg"
},
{
title: "IPKO Promo",
description: "No description available",
start: "2024-12-24T06:00:00.000Z",
stop: "2024-12-24T08:00:00.000Z",
thumbnail: "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg"
},
{
title: "IPKO Promo",
description: "No description available",
start: "2024-12-24T08:00:00.000Z",
stop: "2024-12-24T10:00:00.000Z",
thumbnail: "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg"
}
])
})
it('can handle empty guide', () => {
const result = parser({
content: '{"shows":[]}'
})
expect(result).toMatchObject([])
})
const { parser, url } = require('./ipko.tv.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('2024-12-24', 'YYYY-MM-DD').startOf('day')
const channel = {
site_id: 'ipko-promo',
xmltv_id: 'IPKOPROMO'
}
it('can generate valid url', () => {
expect(url({ date, channel })).toBe('https://stargate.ipko.tv/api/titan.tv.WebEpg/GetWebEpgData')
})
it('can parse response', () => {
const content = `
{
"shows": [
{
"title": "IPKO Promo",
"show_start": 1735012800,
"show_end": 1735020000,
"timestamp": "5:00 - 7:00",
"show_id": "EPG_TvProfil_IPKOPROMO_296105567",
"thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg",
"is_adult": false,
"friendly_id": "ipko_promo_4cf3",
"pg": "",
"genres": [],
"year": 0,
"summary": "",
"categories": "Other",
"stb_only": false,
"is_live": false,
"original_title": "IPKO Promo"
},
{
"title": "IPKO Promo",
"show_start": 1735020000,
"show_end": 1735027200,
"timestamp": "7:00 - 9:00",
"show_id": "EPG_TvProfil_IPKOPROMO_296105568",
"thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg",
"is_adult": false,
"friendly_id": "ipko_promo_416b",
"pg": "",
"genres": [],
"year": 0,
"summary": "",
"categories": "Other",
"stb_only": false,
"is_live": false,
"original_title": "IPKO Promo"
},
{
"title": "IPKO Promo",
"show_start": 1735027200,
"show_end": 1735034400,
"timestamp": "9:00 - 11:00",
"show_id": "EPG_TvProfil_IPKOPROMO_296105569",
"thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg",
"is_adult": false,
"friendly_id": "ipko_promo_2e23",
"pg": "",
"genres": [],
"year": 0,
"summary": "",
"categories": "Other",
"stb_only": false,
"is_live": false,
"original_title": "IPKO Promo"
}
]
}`
const result = parser({ content, channel })
expect(result).toMatchObject([
{
title: 'IPKO Promo',
description: 'No description available',
start: '2024-12-24T04:00:00.000Z',
stop: '2024-12-24T06:00:00.000Z',
thumbnail: 'https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg'
},
{
title: 'IPKO Promo',
description: 'No description available',
start: '2024-12-24T06:00:00.000Z',
stop: '2024-12-24T08:00:00.000Z',
thumbnail: 'https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg'
},
{
title: 'IPKO Promo',
description: 'No description available',
start: '2024-12-24T08:00:00.000Z',
stop: '2024-12-24T10:00:00.000Z',
thumbnail: 'https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg'
}
])
})
it('can handle empty guide', () => {
const result = parser({
content: '{"shows":[]}'
})
expect(result).toMatchObject([])
})