mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Fixes linter errors
This commit is contained in:
parent
57e508fc3b
commit
63c86a2b30
393 changed files with 28447 additions and 28443 deletions
|
@ -1,66 +1,66 @@
|
|||
const stream = require('stream')
|
||||
const csv = require('csv-parser')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'rotana.net',
|
||||
days: 2,
|
||||
url({ channel }) {
|
||||
return `https://rotana.net/triAssets/uploads/2020/11/${channel.site_id}.csv`
|
||||
},
|
||||
request: {
|
||||
method: 'POST'
|
||||
},
|
||||
parser: async function ({ buffer, date }) {
|
||||
let programs = []
|
||||
const items = await parseItems(buffer, date)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item)
|
||||
const stop = parseStop(item)
|
||||
programs.push({
|
||||
title: item['Arabic Event Name'],
|
||||
category: item['Genre'],
|
||||
description: item['Arabic Extended Description'],
|
||||
start: start.toJSON(),
|
||||
stop: stop.toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
const time = `${item['Start Date']} ${item['Start Time']}`
|
||||
|
||||
return dayjs.utc(time, 'DD/MM/YYYY HH:mm:ss:00')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
const time = `${item['End Date']} ${item['End Time']}`
|
||||
|
||||
return dayjs.utc(time, 'DD/MM/YYYY HH:mm:ss:00')
|
||||
}
|
||||
|
||||
function parseItems(buffer, date) {
|
||||
return new Promise(resolve => {
|
||||
let items = []
|
||||
const input = new stream.PassThrough()
|
||||
input.end(buffer)
|
||||
input
|
||||
.pipe(csv())
|
||||
.on('data', data => items.push(data))
|
||||
.on('end', () => {
|
||||
items = items.filter(i => i['Start Date'] === date.format('DD/MM/YYYY'))
|
||||
resolve(items)
|
||||
})
|
||||
.on('error', () => {
|
||||
resolve([])
|
||||
})
|
||||
})
|
||||
}
|
||||
const stream = require('stream')
|
||||
const csv = require('csv-parser')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'rotana.net',
|
||||
days: 2,
|
||||
url({ channel }) {
|
||||
return `https://rotana.net/triAssets/uploads/2020/11/${channel.site_id}.csv`
|
||||
},
|
||||
request: {
|
||||
method: 'POST'
|
||||
},
|
||||
parser: async function ({ buffer, date }) {
|
||||
let programs = []
|
||||
const items = await parseItems(buffer, date)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item)
|
||||
const stop = parseStop(item)
|
||||
programs.push({
|
||||
title: item['Arabic Event Name'],
|
||||
category: item['Genre'],
|
||||
description: item['Arabic Extended Description'],
|
||||
start: start.toJSON(),
|
||||
stop: stop.toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
const time = `${item['Start Date']} ${item['Start Time']}`
|
||||
|
||||
return dayjs.utc(time, 'DD/MM/YYYY HH:mm:ss:00')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
const time = `${item['End Date']} ${item['End Time']}`
|
||||
|
||||
return dayjs.utc(time, 'DD/MM/YYYY HH:mm:ss:00')
|
||||
}
|
||||
|
||||
function parseItems(buffer, date) {
|
||||
return new Promise(resolve => {
|
||||
let items = []
|
||||
const input = new stream.PassThrough()
|
||||
input.end(buffer)
|
||||
input
|
||||
.pipe(csv())
|
||||
.on('data', data => items.push(data))
|
||||
.on('end', () => {
|
||||
items = items.filter(i => i['Start Date'] === date.format('DD/MM/YYYY'))
|
||||
resolve(items)
|
||||
})
|
||||
.on('error', () => {
|
||||
resolve([])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,57 +1,57 @@
|
|||
// npm run grab -- --site=rotana.net
|
||||
|
||||
const { parser, url } = require('./rotana.net.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-11-08', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'KHALIJIA-7',
|
||||
xmltv_id: 'RotanaKhalejia.sa'
|
||||
}
|
||||
const buffer =
|
||||
Buffer.from(`Event ID,Event Name,Arabic Event Name,Start Date,Start Time,End Date,End Time,Short Description,Arabic Short Description,Extended Description,Arabic Extended Description,,Genre,Audio,Video
|
||||
,حسب الظروف,حسب الظروف بدون تترات - Episode 16,07/11/2021,23:30:00:00,08/11/2021,00:00:00:00,,,,,,Drama,,
|
||||
,كورة,كورة,08/11/2021,01:30:00:00,08/11/2021,03:00:00:00,,,,,,Generic,,`)
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ channel, date })
|
||||
expect(result).toBe('https://rotana.net/triAssets/uploads/2020/11/KHALIJIA-7.csv')
|
||||
})
|
||||
|
||||
it('can parse response', done => {
|
||||
parser({ date, channel, buffer })
|
||||
.then(result => {
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-08T01:30:00.000Z',
|
||||
stop: '2021-11-08T03:00:00.000Z',
|
||||
title: 'كورة',
|
||||
category: 'Generic',
|
||||
description: ''
|
||||
}
|
||||
])
|
||||
done()
|
||||
})
|
||||
.catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', done => {
|
||||
parser({
|
||||
date,
|
||||
channel,
|
||||
buffer: Buffer.from('<!DOCTYPE html><html><head></head><body></body></html>')
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toMatchObject([])
|
||||
done()
|
||||
})
|
||||
.catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
// npm run grab -- --site=rotana.net
|
||||
|
||||
const { parser, url } = require('./rotana.net.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-11-08', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'KHALIJIA-7',
|
||||
xmltv_id: 'RotanaKhalejia.sa'
|
||||
}
|
||||
const buffer =
|
||||
Buffer.from(`Event ID,Event Name,Arabic Event Name,Start Date,Start Time,End Date,End Time,Short Description,Arabic Short Description,Extended Description,Arabic Extended Description,,Genre,Audio,Video
|
||||
,حسب الظروف,حسب الظروف بدون تترات - Episode 16,07/11/2021,23:30:00:00,08/11/2021,00:00:00:00,,,,,,Drama,,
|
||||
,كورة,كورة,08/11/2021,01:30:00:00,08/11/2021,03:00:00:00,,,,,,Generic,,`)
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ channel, date })
|
||||
expect(result).toBe('https://rotana.net/triAssets/uploads/2020/11/KHALIJIA-7.csv')
|
||||
})
|
||||
|
||||
it('can parse response', done => {
|
||||
parser({ date, channel, buffer })
|
||||
.then(result => {
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-08T01:30:00.000Z',
|
||||
stop: '2021-11-08T03:00:00.000Z',
|
||||
title: 'كورة',
|
||||
category: 'Generic',
|
||||
description: ''
|
||||
}
|
||||
])
|
||||
done()
|
||||
})
|
||||
.catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', done => {
|
||||
parser({
|
||||
date,
|
||||
channel,
|
||||
buffer: Buffer.from('<!DOCTYPE html><html><head></head><body></body></html>')
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toMatchObject([])
|
||||
done()
|
||||
})
|
||||
.catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue