mirror of
https://github.com/iptv-org/epg
synced 2026-05-06 09:27:03 -04:00
Fixes linter errors
This commit is contained in:
@@ -1,62 +1,62 @@
|
||||
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: 'mysky.com.ph',
|
||||
days: 2,
|
||||
url: 'https://skyepg.mysky.com.ph/Main/getEventsbyType',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.name,
|
||||
description: item.userData.description,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const items = await axios
|
||||
.get('https://skyepg.mysky.com.ph/Main/getEventsbyType')
|
||||
.then(r => r.data.location)
|
||||
.catch(console.log)
|
||||
|
||||
return items.map(item => ({
|
||||
site_id: item.id,
|
||||
name: item.name
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.start, 'YYYY/MM/DD HH:mm', 'Asia/Manila')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.end, 'YYYY/MM/DD HH:mm', 'Asia/Manila')
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
if (!content) return []
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.events)) return []
|
||||
const d = date.format('YYYY/MM/DD')
|
||||
|
||||
return data.events.filter(i => i.location == channel.site_id && i.start.includes(d))
|
||||
}
|
||||
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: 'mysky.com.ph',
|
||||
days: 2,
|
||||
url: 'https://skyepg.mysky.com.ph/Main/getEventsbyType',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.name,
|
||||
description: item.userData.description,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const items = await axios
|
||||
.get('https://skyepg.mysky.com.ph/Main/getEventsbyType')
|
||||
.then(r => r.data.location)
|
||||
.catch(console.log)
|
||||
|
||||
return items.map(item => ({
|
||||
site_id: item.id,
|
||||
name: item.name
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.start, 'YYYY/MM/DD HH:mm', 'Asia/Manila')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.end, 'YYYY/MM/DD HH:mm', 'Asia/Manila')
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
if (!content) return []
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.events)) return []
|
||||
const d = date.format('YYYY/MM/DD')
|
||||
|
||||
return data.events.filter(i => i.location == channel.site_id && i.start.includes(d))
|
||||
}
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
// npm run grab -- --site=mysky.com.ph
|
||||
// npm run channels:parse -- --config=./sites/mysky.com.ph/mysky.com.ph.config.js --output=./sites/mysky.com.ph/mysky.com.ph.channels.xml
|
||||
|
||||
const { parser, url } = require('./mysky.com.ph.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('2022-10-04', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '8',
|
||||
xmltv_id: 'KapamilyaChannel.ph'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://skyepg.mysky.com.ph/Main/getEventsbyType')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'{"events":[{"name":"TV PATROL","location":"8","start":"2022/10/04 19:00","end":"2022/10/04 20:00","userData":{"description":"Description example"}},{"name":"DARNA","location":"8","start":"2022/10/05 20:00","end":"2022/10/05 20:45","userData":{"description":""}},{"name":"Zoe Bakes S1","location":"22","start":"2022/10/04 20:30","end":"2022/10/04 21:00","userData":{"description":"Zo Franois Dad is a beekeeper. So for his birthday, she bakes him a special beehiveshaped cake."}}]}'
|
||||
const result = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-10-04T11:00:00.000Z',
|
||||
stop: '2022-10-04T12:00:00.000Z',
|
||||
title: 'TV PATROL',
|
||||
description: 'Description example'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '',
|
||||
channel,
|
||||
date
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run grab -- --site=mysky.com.ph
|
||||
// npm run channels:parse -- --config=./sites/mysky.com.ph/mysky.com.ph.config.js --output=./sites/mysky.com.ph/mysky.com.ph.channels.xml
|
||||
|
||||
const { parser, url } = require('./mysky.com.ph.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('2022-10-04', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '8',
|
||||
xmltv_id: 'KapamilyaChannel.ph'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://skyepg.mysky.com.ph/Main/getEventsbyType')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'{"events":[{"name":"TV PATROL","location":"8","start":"2022/10/04 19:00","end":"2022/10/04 20:00","userData":{"description":"Description example"}},{"name":"DARNA","location":"8","start":"2022/10/05 20:00","end":"2022/10/05 20:45","userData":{"description":""}},{"name":"Zoe Bakes S1","location":"22","start":"2022/10/04 20:30","end":"2022/10/04 21:00","userData":{"description":"Zo Franois Dad is a beekeeper. So for his birthday, she bakes him a special beehiveshaped cake."}}]}'
|
||||
const result = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-10-04T11:00:00.000Z',
|
||||
stop: '2022-10-04T12:00:00.000Z',
|
||||
title: 'TV PATROL',
|
||||
description: 'Description example'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '',
|
||||
channel,
|
||||
date
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user