mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Replace LF line endings with CRLF
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="chada.ma" lang="fr" xmltv_id="ChadaTV.ma" site_id="1">Chada TV</channel>
|
||||
</channels>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="chada.ma" lang="fr" xmltv_id="ChadaTV.ma" site_id="1">Chada TV</channel>
|
||||
</channels>
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
const cheerio = require('cheerio')
|
||||
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: 'chada.ma',
|
||||
channels: 'chada.ma.channels.xml',
|
||||
days: 1,
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
url() {
|
||||
return 'https://chada.ma/fr/chada-tv/grille-tv/'
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
const $ = cheerio.load(content)
|
||||
const programs = []
|
||||
|
||||
$('#stopfix .posts-area h2').each((i, element) => {
|
||||
const timeRange = $(element).text().trim()
|
||||
const [start, stop] = timeRange.split(' - ').map(t => parseProgramTime(t.trim()))
|
||||
|
||||
const titleElement = $(element).next('div').next('h3')
|
||||
const title = titleElement.text().trim()
|
||||
|
||||
const description = titleElement.next('div').text().trim() || 'No description available'
|
||||
|
||||
programs.push({
|
||||
title,
|
||||
description,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseProgramTime(timeStr) {
|
||||
const timeZone = 'Africa/Casablanca'
|
||||
const currentDate = dayjs().format('YYYY-MM-DD')
|
||||
|
||||
return dayjs
|
||||
.tz(`${currentDate} ${timeStr}`, 'YYYY-MM-DD HH:mm', timeZone)
|
||||
.format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
}
|
||||
const cheerio = require('cheerio')
|
||||
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: 'chada.ma',
|
||||
channels: 'chada.ma.channels.xml',
|
||||
days: 1,
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
url() {
|
||||
return 'https://chada.ma/fr/chada-tv/grille-tv/'
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
const $ = cheerio.load(content)
|
||||
const programs = []
|
||||
|
||||
$('#stopfix .posts-area h2').each((i, element) => {
|
||||
const timeRange = $(element).text().trim()
|
||||
const [start, stop] = timeRange.split(' - ').map(t => parseProgramTime(t.trim()))
|
||||
|
||||
const titleElement = $(element).next('div').next('h3')
|
||||
const title = titleElement.text().trim()
|
||||
|
||||
const description = titleElement.next('div').text().trim() || 'No description available'
|
||||
|
||||
programs.push({
|
||||
title,
|
||||
description,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseProgramTime(timeStr) {
|
||||
const timeZone = 'Africa/Casablanca'
|
||||
const currentDate = dayjs().format('YYYY-MM-DD')
|
||||
|
||||
return dayjs
|
||||
.tz(`${currentDate} ${timeStr}`, 'YYYY-MM-DD HH:mm', timeZone)
|
||||
.format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
const { parser, url } = require('./chada.ma.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
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)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url()).toBe('https://chada.ma/fr/chada-tv/grille-tv/')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = dayjs(p.start).tz('Africa/Casablanca').format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
p.stop = dayjs(p.stop).tz('Africa/Casablanca').format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: 'Bloc Prime + Clips',
|
||||
description: 'No description available',
|
||||
start: dayjs.tz('00:00', 'HH:mm', 'Africa/Casablanca').format('YYYY-MM-DDTHH:mm:ssZ'),
|
||||
stop: dayjs.tz('09:00', 'HH:mm', 'Africa/Casablanca').format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./chada.ma.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
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)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url()).toBe('https://chada.ma/fr/chada-tv/grille-tv/')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = dayjs(p.start).tz('Africa/Casablanca').format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
p.stop = dayjs(p.stop).tz('Africa/Casablanca').format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: 'Bloc Prime + Clips',
|
||||
description: 'No description available',
|
||||
start: dayjs.tz('00:00', 'HH:mm', 'Africa/Casablanca').format('YYYY-MM-DDTHH:mm:ssZ'),
|
||||
stop: dayjs.tz('09:00', 'HH:mm', 'Africa/Casablanca').format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# chada.ma
|
||||
|
||||
https://chada.ma/fr/chada-tv/grille-tv/
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=chada.ma
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
npm test --- chada.ma
|
||||
# chada.ma
|
||||
|
||||
https://chada.ma/fr/chada-tv/grille-tv/
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=chada.ma
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
npm test --- chada.ma
|
||||
|
||||
Reference in New Issue
Block a user