mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Merge pull request #580 from iptv-org/add-kan.org.il
Add guide from kan.org.il
This commit is contained in:
commit
7c00c6e99d
4 changed files with 123 additions and 0 deletions
17
.github/workflows/kan.org.il.yml
vendored
Normal file
17
.github/workflows/kan.org.il.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
name: allente.se
|
||||||
|
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 }}
|
51
sites/kan.org.il/kan.org.il.config.js
Normal file
51
sites/kan.org.il/kan.org.il.config.js
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
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: 'kan.org.il',
|
||||||
|
url: function ({ channel, date }) {
|
||||||
|
return `https://www.kan.org.il/tv-guide/tv_guidePrograms.ashx?stationID=${
|
||||||
|
channel.site_id
|
||||||
|
}&day=${date.format('DD/MM/YYYY')}`
|
||||||
|
},
|
||||||
|
parser: function ({ content }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content)
|
||||||
|
items.forEach(item => {
|
||||||
|
programs.push({
|
||||||
|
title: item.title,
|
||||||
|
description: item.live_desc,
|
||||||
|
icon: item.picture_code,
|
||||||
|
start: parseStart(item),
|
||||||
|
stop: parseStop(item)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart(item) {
|
||||||
|
if (!item.start_time) return null
|
||||||
|
|
||||||
|
return dayjs.tz(item.start_time, 'YYYY-MM-DDTHH:mm:ss', 'Asia/Jerusalem')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStop(item) {
|
||||||
|
if (!item.end_time) return null
|
||||||
|
|
||||||
|
return dayjs.tz(item.end_time, 'YYYY-MM-DDTHH:mm:ss', 'Asia/Jerusalem')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
if (!Array.isArray(data)) return []
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
47
sites/kan.org.il/kan.org.il.test.js
Normal file
47
sites/kan.org.il/kan.org.il.test.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
// npx epg-grabber --config=sites/kan.org.il/kan.org.il.config.js --channels=sites/kan.org.il/kan.org.il_il.channels.xml --output=guide.xml --days=2
|
||||||
|
|
||||||
|
const { parser, url } = require('./kan.org.il.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: '19',
|
||||||
|
xmltv_id: 'KANEducational.il'
|
||||||
|
}
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel, date })).toBe(
|
||||||
|
'https://www.kan.org.il/tv-guide/tv_guidePrograms.ashx?stationID=19&day=06/03/2022'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = `[{"title":"ארץ מולדת - בין תורכיה לבריטניה","start_time":"2022-03-06T00:05:37","end_time":"2022-03-06T00:27:12","id":"2598","age_category_desc":"0","epg_name":"ארץ מולדת","title1":"ארץ מולדת - בין תורכיה לבריטניה","chapter_number":"9","live_desc":"קבוצת תלמידים מתארגנת בפרוץ מלחמת העולם הראשונה להגיש עזרה לישוב. באמצעות התלמידים לומד הצופה על בעיותיו של הישוב בתקופת המלחמה, והתלבטותו בין נאמנות לשלטון העות'מאני לבין תקוותיו מהבריטים הכובשים.","Station_Radio":"0","Station_Id":"20","stationUrlScheme":"kan11://plugin/?type=player&plugin_identifier=kan_player&ds=general-provider%3A%2F%2FfetchData%3Ftype%3DFEED_JSON%26url%3DaHR0cHM6Ly93d3cua2FuLm9yZy5pbC9hcHBLYW4vbGl2ZVN0YXRpb25zLmFzaHg%3D&id=4","program_code":"3671","picture_code":"https://kanweb.blob.core.windows.net/download/pictures/2021/1/20/imgid=45847_Z.jpeg","program_image":"","station_image":"Logo_Image_Logo20_img__8.jpg","program_id":"","timezone":"2"}]`
|
||||||
|
const result = parser({ content }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(result).toMatchObject([
|
||||||
|
{
|
||||||
|
start: '2022-03-05T22:05:37.000Z',
|
||||||
|
stop: '2022-03-05T22:27:12.000Z',
|
||||||
|
title: 'ארץ מולדת - בין תורכיה לבריטניה',
|
||||||
|
description:
|
||||||
|
"קבוצת תלמידים מתארגנת בפרוץ מלחמת העולם הראשונה להגיש עזרה לישוב. באמצעות התלמידים לומד הצופה על בעיותיו של הישוב בתקופת המלחמה, והתלבטותו בין נאמנות לשלטון העות'מאני לבין תקוותיו מהבריטים הכובשים.",
|
||||||
|
icon: 'https://kanweb.blob.core.windows.net/download/pictures/2021/1/20/imgid=45847_Z.jpeg'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const result = parser({
|
||||||
|
content: `[]`
|
||||||
|
})
|
||||||
|
expect(result).toMatchObject([])
|
||||||
|
})
|
8
sites/kan.org.il/kan.org.il_il.channels.xml
Normal file
8
sites/kan.org.il/kan.org.il_il.channels.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<site site="kan.org.il">
|
||||||
|
<channels>
|
||||||
|
<channel lang="he" xmltv_id="Kan11.il" site_id="1">כאן 11</channel>
|
||||||
|
<channel lang="he" xmltv_id="KanEducational.il" site_id="19">חינוכית</channel>
|
||||||
|
<channel lang="he" xmltv_id="Makan33.il" site_id="2">مكان</channel>
|
||||||
|
</channels>
|
||||||
|
</site>
|
Loading…
Add table
Add a link
Reference in a new issue