Merge pull request #3078 from iptv-org/add-aljazeera.com

Add aljazeera.com
This commit is contained in:
PopeyeTheSai10r authored and GitHub committed 2026-04-19 11:33:24 -07:00
commit 95e55afbd5
5 files changed
+160

No files matched your search

@@ -0,0 +1 @@
{"data":{"post":{"title":"Schedule","id":"568783","content":"","schedule":[{"showDay":"Friday","showTimeslot":"00:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"01:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"02:00","showName":"NEWS 30min","showDescription":"Latest news and analysis from around the world.","duration":"00:30:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"02:30","showName":"Counting the Cost","showDescription":"From tolls to blockades - who really controls access to the Strait of Hormuz?","duration":"00:30:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"03:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"04:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"05:00","showName":"NEWS 30min","showDescription":"Latest news and analysis from around the world.","duration":"00:30:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"05:30","showName":"Inside Story","showDescription":"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.","duration":"00:30:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"06:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"07:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"08:00","showName":"NEWS 30min","showDescription":"Latest news and analysis from around the world.","duration":"00:30:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"08:30","showName":"Talk to Al Jazeera : Zohran Mamdani","showDescription":"New York City’s mayor reflects on his first 100 days in office, from childcare to affordability, bigotry, war and the future of Democrats.","duration":"00:30:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"09:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"10:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"11:00","showName":"NEWS 30min","showDescription":"Latest news and analysis from around the world.","duration":"00:30:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"11:30","showName":"Inside Story","showDescription":"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.","duration":"00:30:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"12:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"13:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"14:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"15:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"16:00","showName":"NEWSHOUR","showDescription":"Latest news and in-depth analysis from around the world.","duration":"01:00:0","startDate":"1776384000","__typename":"Schedule"},{"showDay":"Friday","showTimeslot":"17:00","showName":"NEWS 30min","showDescription":"Latest news and analysis from around the world.","duration":"00:30:0","staLine truncated
@@ -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>
@@ -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
View 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
View 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
```