mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Fix linter issues
This commit is contained in:
parent
8b0952b915
commit
e8f89b216c
4 changed files with 255 additions and 264 deletions
|
@ -2,7 +2,6 @@ const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
const cheerio = require('cheerio')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
|
@ -16,21 +15,21 @@ module.exports = {
|
||||||
ttl: 60 * 60 * 1000 // 1 hour
|
ttl: 60 * 60 * 1000 // 1 hour
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
url: function ({date, channel}) {
|
url: function ({ date, channel }) {
|
||||||
// Get the epoch timestamp
|
// Get the epoch timestamp
|
||||||
const todayEpoch = date.startOf('day').utc().valueOf()
|
const todayEpoch = date.startOf('day').utc().valueOf()
|
||||||
// Get the epoch timestamp for the next day
|
// Get the epoch timestamp for the next day
|
||||||
const nextDayEpoch = date.add(1, 'day').startOf('day').utc().valueOf()
|
const nextDayEpoch = date.add(1, 'day').startOf('day').utc().valueOf()
|
||||||
return `https://epg.cyta.com.cy/api/mediacatalog/fetchEpg?startTimeEpoch=${todayEpoch}&endTimeEpoch=${nextDayEpoch}&language=1&channelIds=${channel.site_id}`
|
return `https://epg.cyta.com.cy/api/mediacatalog/fetchEpg?startTimeEpoch=${todayEpoch}&endTimeEpoch=${nextDayEpoch}&language=1&channelIds=${channel.site_id}`
|
||||||
},
|
},
|
||||||
parser: function ({content}) {
|
parser: function ({ content }) {
|
||||||
const data = JSON.parse(content)
|
const data = JSON.parse(content)
|
||||||
const programs = []
|
const programs = []
|
||||||
|
|
||||||
data.channelEpgs.forEach(channel => {
|
data.channelEpgs.forEach(channel => {
|
||||||
channel.epgPlayables.forEach(epg => {
|
channel.epgPlayables.forEach(epg => {
|
||||||
const start = new Date(epg.startTime).toISOString();
|
const start = new Date(epg.startTime).toISOString()
|
||||||
const stop = new Date(epg.endTime).toISOString();
|
const stop = new Date(epg.endTime).toISOString()
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: epg.name,
|
title: epg.name,
|
||||||
|
@ -45,7 +44,7 @@ module.exports = {
|
||||||
async channels() {
|
async channels() {
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get(`https://epg.cyta.com.cy/api/mediacatalog/fetchChannels?language=1`)
|
.get('https://epg.cyta.com.cy/api/mediacatalog/fetchChannels?language=1')
|
||||||
.then(r => r.data)
|
.then(r => r.data)
|
||||||
.catch(console.log)
|
.catch(console.log)
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,7 @@ it('can parse response', () => {
|
||||||
]
|
]
|
||||||
}`
|
}`
|
||||||
|
|
||||||
const result = parser({ content }).map(p => {
|
const result = parser({ content })
|
||||||
p.start = p.start
|
|
||||||
p.stop = p.stop
|
|
||||||
return p
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(result).toMatchObject([
|
expect(result).toMatchObject([
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,6 @@ dayjs.extend(utc)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'stod2.is',
|
site: 'stod2.is',
|
||||||
channels: 'stod2.is.channels.xml',
|
|
||||||
days: 7,
|
days: 7,
|
||||||
request: {
|
request: {
|
||||||
cache: {
|
cache: {
|
||||||
|
|
|
@ -3,14 +3,11 @@ const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
const axios = require('axios')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
|
|
||||||
jest.mock('axios')
|
|
||||||
|
|
||||||
const date = dayjs.utc('2025-01-03', 'YYYY-MM-DD').startOf('day')
|
const date = dayjs.utc('2025-01-03', 'YYYY-MM-DD').startOf('day')
|
||||||
const channel = { site_id: 'stod2', xmltv_id: 'Stod2.is' }
|
const channel = { site_id: 'stod2', xmltv_id: 'Stod2.is' }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue