Initial Commit
This commit is contained in:
16
sites/rotana.net/rotana.net.channels.xml
Normal file
16
sites/rotana.net/rotana.net.channels.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="rotana.net">
|
||||
<channels>
|
||||
<channel lang="ar" xmltv_id="LBC.sa" site_id="LBC-15">LBC</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaAflamPlusHD.sa" site_id="AFLAM-1-1">Rotana Aflam+</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaAmerica.sa" site_id="AMERICA-11">Rotana America</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaCinemaEgypt.eg" site_id="CINEMA-EGY-11">Rotana Cinema Egypt</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaCinemaKSA.sa" site_id="CINEMA-10">Rotana Cinema KSA</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaClassic.sa" site_id="CLASSIC-12">Rotana Classic</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaComedy.sa" site_id="COMEDY-13">Rotana Comedy</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaDrama.sa" site_id="DRAMA-13">Rotana Drama</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaKhalijia.sa" site_id="KHALIJIA-11">Rotana Khalejia</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaKids.sa" site_id="KIDS-12">Rotana Kids</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaPlusHD.sa" site_id="ROTANA-HD-11">Rotana+</channel>
|
||||
</channels>
|
||||
</site>
|
||||
71
sites/rotana.net/rotana.net.config.js
Normal file
71
sites/rotana.net/rotana.net.config.js
Normal file
@@ -0,0 +1,71 @@
|
||||
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,
|
||||
skip: true, // NOTE: there is no program for the current date on the site
|
||||
url({ channel, date }) {
|
||||
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 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([])
|
||||
})
|
||||
})
|
||||
}
|
||||
57
sites/rotana.net/rotana.net.test.js
Normal file
57
sites/rotana.net/rotana.net.test.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// npx epg-grabber --config=sites/rotana.net/rotana.net.config.js --channels=sites/rotana.net/rotana.net.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, request } = 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()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user