mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create rotana.net.config.js
This commit is contained in:
parent
9fc2eb3cb2
commit
41f2af51f3
1 changed files with 72 additions and 0 deletions
72
sites/rotana.net/rotana.net.config.js
Normal file
72
sites/rotana.net/rotana.net.config.js
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
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',
|
||||||
|
url({ channel, date }) {
|
||||||
|
return `https://rotana.net/triAssets/uploads/2020/${date.format('MM')}/${channel.site_id}.csv`
|
||||||
|
},
|
||||||
|
request: {
|
||||||
|
method: 'POST'
|
||||||
|
},
|
||||||
|
logo({ channel }) {
|
||||||
|
return channel.logo
|
||||||
|
},
|
||||||
|
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 parseIcon(item) {
|
||||||
|
return item.pictures && item.pictures.length ? item.pictures[0].href : null
|
||||||
|
}
|
||||||
|
|
||||||
|
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([])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue