mirror of
https://github.com/iptv-org/epg
synced 2026-05-08 18:36:59 -04:00
Merge pull request #3078 from iptv-org/add-aljazeera.com
Add aljazeera.com
This commit is contained in:
1
sites/aljazeera.com/__data__/content.json
Normal file
1
sites/aljazeera.com/__data__/content.json
Normal file
File diff suppressed because one or more lines are too long
6
sites/aljazeera.com/aljazeera.com.channels.xml
Normal file
6
sites/aljazeera.com/aljazeera.com.channels.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<channels>
|
||||||
|
<channel site="aljazeera.com" site_id="aja#aj2" lang="ar" xmltv_id="AlJazeera2.qa@HD">Al Jazeera 2</channel>
|
||||||
|
<channel site="aljazeera.com" site_id="aja#" lang="ar" xmltv_id="AlJazeera.qa@Arabic">Al Jazeera Arabic</channel>
|
||||||
|
<channel site="aljazeera.com" site_id="aje#" lang="en" xmltv_id="AlJazeera.qa@English">Al Jazeera English</channel>
|
||||||
|
</channels>
|
||||||
77
sites/aljazeera.com/aljazeera.com.config.js
Normal file
77
sites/aljazeera.com/aljazeera.com.config.js
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'aljazeera.com',
|
||||||
|
days: 2,
|
||||||
|
url({ channel }) {
|
||||||
|
const [site_id, suffix] = channel.site_id.split('#')
|
||||||
|
const postName = suffix ? `schedule-${suffix}` : 'schedule'
|
||||||
|
const variables = JSON.stringify({
|
||||||
|
postName,
|
||||||
|
preview: ''
|
||||||
|
})
|
||||||
|
const extensions = JSON.stringify({})
|
||||||
|
|
||||||
|
return `https://www.aljazeera.com/graphql?wp-site=${site_id}&operationName=ArchipelagoSchedulePageQuery&variables=${variables}&extensions=${extensions}`
|
||||||
|
},
|
||||||
|
request: {
|
||||||
|
headers({ channel }) {
|
||||||
|
const [site_id] = channel.site_id.split('#')
|
||||||
|
|
||||||
|
return {
|
||||||
|
'wp-site': site_id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parser({ content, date }) {
|
||||||
|
const items = parseItems(content, date)
|
||||||
|
|
||||||
|
return items.map(item => {
|
||||||
|
const start = parseStart(item, date)
|
||||||
|
const duration = parseDuration(item.duration)
|
||||||
|
const stop = start.add(duration, 's')
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: item.showName,
|
||||||
|
description: item.showDescription,
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
channels() {
|
||||||
|
return [
|
||||||
|
{ site_id: 'aje#', lang: 'en', xmltv_id: 'AlJazeera.qa@English', name: 'Al Jazeera English' },
|
||||||
|
{ site_id: 'aja#', lang: 'ar', xmltv_id: 'AlJazeera.qa@Arabic', name: 'Al Jazeera Arabic' },
|
||||||
|
{ site_id: 'aja#aj2', lang: 'ar', xmltv_id: 'AlJazeera2.qa@HD', name: 'Al Jazeera 2' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart(item, date) {
|
||||||
|
return dayjs(`${date.format('YYYY-MM-DD')} ${item.showTimeslot}`, 'YYYY-MM-DD HH:mm').utc()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDuration(duration) {
|
||||||
|
const [, HH, mm, ss] = duration.match(/(\d+):(\d+)(?::(\d+))?/)
|
||||||
|
|
||||||
|
return parseInt(HH) * 3600 + parseInt(mm) * 60 + parseInt(ss || 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, date) {
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
if (!data?.data?.post || !Array.isArray(data.data.post.schedule)) return []
|
||||||
|
|
||||||
|
const startOfDay = date.startOf('day')
|
||||||
|
|
||||||
|
return data.data.post.schedule.filter(item => item.startDate === startOfDay.unix().toString())
|
||||||
|
} catch {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
55
sites/aljazeera.com/aljazeera.com.test.js
Normal file
55
sites/aljazeera.com/aljazeera.com.test.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
const { parser, url, request } = require('./aljazeera.com.config.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
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('2026-04-22', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = { site_id: 'aje#' }
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel })).toBe(
|
||||||
|
'https://www.aljazeera.com/graphql?wp-site=aje&operationName=ArchipelagoSchedulePageQuery&variables={"postName":"schedule","preview":""}&extensions={}'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid request headers', () => {
|
||||||
|
expect(request.headers({ channel })).toMatchObject({
|
||||||
|
'wp-site': 'aje'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||||
|
|
||||||
|
const results = parser({ content, date }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(results.length).toBe(35)
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
title: 'NEWSHOUR',
|
||||||
|
description: 'Latest news and in-depth analysis from around the world.',
|
||||||
|
start: '2026-04-21T12:00:00.000Z',
|
||||||
|
stop: '2026-04-21T13:00:00.000Z'
|
||||||
|
})
|
||||||
|
expect(results[34]).toMatchObject({
|
||||||
|
title: 'Inside Story',
|
||||||
|
description:
|
||||||
|
'Beyond the headlines to the heart of the news of the day. Al Jazeera gets the Inside Story from some of the best minds from around the globe.',
|
||||||
|
start: '2026-04-22T11:30:00.000Z',
|
||||||
|
stop: '2026-04-22T12:00:00.000Z'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const results = parser({ content: '', date })
|
||||||
|
|
||||||
|
expect(results).toMatchObject([])
|
||||||
|
})
|
||||||
21
sites/aljazeera.com/readme.md
Normal file
21
sites/aljazeera.com/readme.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# aljazeera.com
|
||||||
|
|
||||||
|
https://www.aljazeera.com/schedule
|
||||||
|
|
||||||
|
### Download the guide
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run grab --- --sites=aljazeera.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update channel list
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run channels:parse --- --config=./sites/aljazeera.com/aljazeera.com.config.js --output=./sites/aljazeera.com/aljazeera.com.channels.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm test --- aljazeera.com
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user