mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 09:30:06 -04:00
Merge pull request #581 from iptv-org/add-i24news.tv
Add guide from i24news.tv
This commit is contained in:
commit
581f43f4a5
6 changed files with 148 additions and 0 deletions
17
.github/workflows/i24news.tv.yml
vendored
Normal file
17
.github/workflows/i24news.tv.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: i24news.tv
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
workflow_run:
|
||||
workflows: [_trigger]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
load:
|
||||
uses: ./.github/workflows/_load.yml
|
||||
with:
|
||||
site: ${{github.workflow}}
|
||||
secrets:
|
||||
APP_ID: ${{ secrets.APP_ID }}
|
||||
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
|
66
sites/i24news.tv/i24news.tv.config.js
Normal file
66
sites/i24news.tv/i24news.tv.config.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
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: 'i24news.tv',
|
||||
url: function ({ channel }) {
|
||||
const [lang] = channel.site_id.split('#')
|
||||
|
||||
return `https://api.i24news.tv/v2/${lang}/schedules/world`
|
||||
},
|
||||
parser: function ({ content, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, date)
|
||||
items.forEach(item => {
|
||||
if (!item.show) return
|
||||
programs.push({
|
||||
title: item.show.title,
|
||||
description: item.show.body,
|
||||
icon: parseIcon(item),
|
||||
start: parseStart(item, date),
|
||||
stop: parseStop(item, date)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.show.image ? item.show.image.href : null
|
||||
}
|
||||
|
||||
function parseStart(item, date) {
|
||||
if (!item.startHour) return null
|
||||
|
||||
return dayjs.tz(
|
||||
`${date.format('YYYY-MM-DD')} ${item.startHour}`,
|
||||
'YYYY-MM-DD HH:mm',
|
||||
'Asia/Jerusalem'
|
||||
)
|
||||
}
|
||||
|
||||
function parseStop(item, date) {
|
||||
if (!item.endHour) return null
|
||||
|
||||
return dayjs.tz(
|
||||
`${date.format('YYYY-MM-DD')} ${item.endHour}`,
|
||||
'YYYY-MM-DD HH:mm',
|
||||
'Asia/Jerusalem'
|
||||
)
|
||||
}
|
||||
|
||||
function parseItems(content, date) {
|
||||
const data = JSON.parse(content)
|
||||
if (!Array.isArray(data)) return []
|
||||
let day = date.day() - 1
|
||||
day = day < 0 ? 6 : day
|
||||
|
||||
return data.filter(item => item.day === day)
|
||||
}
|
47
sites/i24news.tv/i24news.tv.test.js
Normal file
47
sites/i24news.tv/i24news.tv.test.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
// npx epg-grabber --config=sites/i24news.tv/i24news.tv.config.js --channels=sites/i24news.tv/i24news.tv_il-ar.channels.xml --output=guide.xml --days=2
|
||||
// npx epg-grabber --config=sites/i24news.tv/i24news.tv.config.js --channels=sites/i24news.tv/i24news.tv_il-en.channels.xml --output=guide.xml --days=2
|
||||
// npx epg-grabber --config=sites/i24news.tv/i24news.tv.config.js --channels=sites/i24news.tv/i24news.tv_il-fr.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url } = require('./i24news.tv.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('2022-03-06', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'ar#',
|
||||
xmltv_id: 'I24NewsArabic.il'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel })).toBe('https://api.i24news.tv/v2/ar/schedules/world')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `[{"id":348995,"startHour":"22:30","endHour":"23:00","day":5,"firstDiffusion":false,"override":false,"show":{"parsedBody":[{"type":"text","text":"Special Edition"}],"id":131,"title":"تغطية خاصة","body":"Special Edition","slug":"Special-Edition-تغطية-خاصة","visible":true,"image":{"id":1142467,"credit":"","legend":"","href":"https://cdn.i24news.tv/uploads/a1/be/85/20/69/6f/32/1c/ed/b0/f8/5c/f6/1c/40/f9/a1be8520696f321cedb0f85cf61c40f9.png"}}},{"id":349023,"startHour":"15:00","endHour":"15:28","day":6,"firstDiffusion":false,"override":false,"show":{"parsedBody":[{"type":"text","text":"Special Edition"}],"id":131,"title":"تغطية خاصة","body":"Special Edition","slug":"Special-Edition-تغطية-خاصة","visible":true,"image":{"id":1142467,"credit":"","legend":"","href":"https://cdn.i24news.tv/uploads/a1/be/85/20/69/6f/32/1c/ed/b0/f8/5c/f6/1c/40/f9/a1be8520696f321cedb0f85cf61c40f9.png"}}}]`
|
||||
const result = parser({ content, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-03-06T13:00:00.000Z',
|
||||
stop: '2022-03-06T13:28:00.000Z',
|
||||
title: 'تغطية خاصة',
|
||||
description: 'Special Edition',
|
||||
icon: 'https://cdn.i24news.tv/uploads/a1/be/85/20/69/6f/32/1c/ed/b0/f8/5c/f6/1c/40/f9/a1be8520696f321cedb0f85cf61c40f9.png'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `[]`,
|
||||
date
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
6
sites/i24news.tv/i24news.tv_il-ar.channels.xml
Normal file
6
sites/i24news.tv/i24news.tv_il-ar.channels.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="i24news.tv">
|
||||
<channels>
|
||||
<channel lang="ar" xmltv_id="I24NewsArabic.il" site_id="ar#">i24News Arabic</channel>
|
||||
</channels>
|
||||
</site>
|
6
sites/i24news.tv/i24news.tv_il-en.channels.xml
Normal file
6
sites/i24news.tv/i24news.tv_il-en.channels.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="i24news.tv">
|
||||
<channels>
|
||||
<channel lang="en" xmltv_id="I24NewsEnglish.il" site_id="en#">i24News English</channel>
|
||||
</channels>
|
||||
</site>
|
6
sites/i24news.tv/i24news.tv_il-fr.channels.xml
Normal file
6
sites/i24news.tv/i24news.tv_il-fr.channels.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="i24news.tv">
|
||||
<channels>
|
||||
<channel lang="fr" xmltv_id="I24NewsFrancais.il" site_id="fr#">i24 News Français</channel>
|
||||
</channels>
|
||||
</site>
|
Loading…
Add table
Add a link
Reference in a new issue