mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Merge pull request #212 from iptv-org/add-rotana-net
Add guide from rotana.net
This commit is contained in:
commit
d245c28f5e
5 changed files with 175 additions and 0 deletions
23
package-lock.json
generated
23
package-lock.json
generated
|
@ -10,6 +10,7 @@
|
|||
"axios": "^0.21.1",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"commander": "^8.2.0",
|
||||
"csv-parser": "^3.0.0",
|
||||
"dayjs": "^1.10.4",
|
||||
"epg-grabber": "^0.12.1",
|
||||
"epg-parser": "^0.1.6",
|
||||
|
@ -1625,6 +1626,20 @@
|
|||
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz",
|
||||
"integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg=="
|
||||
},
|
||||
"node_modules/csv-parser": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz",
|
||||
"integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==",
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.0"
|
||||
},
|
||||
"bin": {
|
||||
"csv-parser": "bin/csv-parser"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/data-urls": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz",
|
||||
|
@ -5691,6 +5706,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"csv-parser": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz",
|
||||
"integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"data-urls": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"axios": "^0.21.1",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"commander": "^8.2.0",
|
||||
"csv-parser": "^3.0.0",
|
||||
"dayjs": "^1.10.4",
|
||||
"epg-grabber": "^0.12.1",
|
||||
"epg-parser": "^0.1.6",
|
||||
|
|
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([])
|
||||
})
|
||||
})
|
||||
}
|
63
sites/rotana.net/rotana.net.test.js
Normal file
63
sites/rotana.net/rotana.net.test.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
// npx epg-grabber --config=sites/rotana.net/rotana.net.config.js --channels=sites/rotana.net/rotana.net_sa.channels.xml --output=.gh-pages/guides/sa/rotana.net.epg.xml --days=2
|
||||
|
||||
const { parser, url, logo, 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',
|
||||
logo: 'https://rotana.net/triAssets/uploads/2020/11/khalijiat.png'
|
||||
}
|
||||
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 get logo url', () => {
|
||||
const result = logo({ channel })
|
||||
expect(result).toBe('https://rotana.net/triAssets/uploads/2020/11/khalijiat.png')
|
||||
})
|
||||
|
||||
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()
|
||||
})
|
||||
})
|
16
sites/rotana.net/rotana.net_sa.channels.xml
Normal file
16
sites/rotana.net/rotana.net_sa.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-10" logo="https://rotana.net/triAssets/uploads/2020/11/lbc.png">LBC</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaAflamPlus.sa" site_id="Aflam-Plus" logo="https://rotana.net/triAssets/uploads/2020/11/aflam-plus.png">Rotana Aflam+</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaAmerica.sa" site_id="Amreca-1" logo="https://rotana.net/triAssets/uploads/2020/11/america.png">Rotana America</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaCinemaEgypt.sa" site_id="cinem-EGY-1" logo="https://rotana.net/triAssets/uploads/2020/11/cinema-egypt.png">Rotana Cinema Egypt</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaCinemaKSA.sa" site_id="Cinema-KSA-1" logo="https://rotana.net/triAssets/uploads/2020/11/cinema.png">Rotana Cinema KSA</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaClassic.sa" site_id="Classic" logo="https://rotana.net/triAssets/uploads/2020/11/classic.png">Rotana Classic</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaComedy.sa" site_id="COMEDY-9" logo="https://rotana.net/triAssets/uploads/2020/11/comedy.png">Rotana Comedy</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaDrama.sa" site_id="DRAMA-9" logo="https://rotana.net/triAssets/uploads/2020/11/drama.png">Rotana Drama</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaKhalejia.sa" site_id="KHALIJIA-7" logo="https://rotana.net/triAssets/uploads/2020/11/khalijiat.png">Rotana Khalejia</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaKids.sa" site_id="KIDS-8" logo="https://rotana.net/triAssets/uploads/2020/11/kids.png">Rotana Kids</channel>
|
||||
<channel lang="ar" xmltv_id="RotanaPlus.sa" site_id="Rotana-HD-1" logo="https://rotana.net/triAssets/uploads/2020/11/hd.png">Rotana+</channel>
|
||||
</channels>
|
||||
</site>
|
Loading…
Add table
Add a link
Reference in a new issue