mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 09:30:06 -04:00
commit
a603a29a90
4 changed files with 132 additions and 0 deletions
17
.github/workflows/raiplay.it.yml
vendored
Normal file
17
.github/workflows/raiplay.it.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: raiplay.it
|
||||
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 }}
|
49
sites/raiplay.it/raiplay.it.config.js
Normal file
49
sites/raiplay.it/raiplay.it.config.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'raiplay.it',
|
||||
url: function ({ date, channel }) {
|
||||
return `https://www.raiplay.it/palinsesto/app/${channel.site_id}/${date.format('DD-MM-YYYY')}.json`
|
||||
},
|
||||
parser: function ({ content, date }) {
|
||||
const programs = []
|
||||
const data = JSON.parse(content)
|
||||
if (!data.events) return programs
|
||||
|
||||
data.events.forEach(item => {
|
||||
if (item.name && item.hour && item.duration_in_minutes) {
|
||||
const startDate = dayjs
|
||||
.utc(item.hour, 'HH:mm')
|
||||
.set('D', date.get('D'))
|
||||
.set('M', date.get('M'))
|
||||
.set('y', date.get('y'))
|
||||
const start = startDate.toJSON()
|
||||
const duration = parseInt(item.duration_in_minutes)
|
||||
const stopDate = startDate.add(duration,'m')
|
||||
const stop = stopDate.toJSON()
|
||||
|
||||
programs.push({
|
||||
title: item.name || item.program.name,
|
||||
description: item.description,
|
||||
season: item.season || null,
|
||||
episode: item.episode || null,
|
||||
start,
|
||||
stop,
|
||||
icon: parseIcon(item)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return cover = item.image ? `https://www.raiplay.it${item.image}` : null
|
||||
|
||||
}
|
47
sites/raiplay.it/raiplay.it.test.js
Normal file
47
sites/raiplay.it/raiplay.it.test.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
// npx epg-grabber --config=sites/raiplay.it/raiplay.it.config.js --channels=sites/raiplay.it/raiplay.it_it.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url } = require('./raiplay.it.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-05-03', 'YYYY-MM-DD')
|
||||
const channel = {
|
||||
site_id: 'rai-2',
|
||||
xmltv_id: 'Rai2.it'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://www.raiplay.it/palinsesto/app/rai-2/03-05-2022.json'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{ "id": "Page-e120a813-1b92-4057-a214-15943d95aa68", "title": "Pagina Palinsesto", "channel": "Rai 2", "date": "03-05-2022", "events": [ { "id": "ContentItem-2f81030d-803b-456a-9ea5-40233234fd9d", "name": "The Good Doctor S3E5 - La prima volta", "episode_title": "La prima volta", "episode": "5", "season": "3", "description": "Shaun affronta il suo primo intervento. Il caso si rivela complicato e, nonostante Shaun abbia un'idea geniale, sarà Andrews a portare a termine l'operazione.", "channel": "Rai 2", "date": "03/05/2022", "hour": "19:40", "duration": "00:50:00", "duration_in_minutes": "50 min", "path_id": "", "weblink": "", "event_weblink": "/dirette/rai2/The-Good-Doctor-S3E5---La-prima-volta-2f81030d-803b-456a-9ea5-40233234fd9d.html", "has_video": false, "image": "/dl/img/2020/03/09/1583748471860_dddddd.jpg", "playlist_id": "11430689", "program": { "name": "The Good Doctor", "path_id": "/programmi/thegooddoctor.json", "info_url": "/programmi/info/757edeac-6fff-4dea-afcd-0bcb39f9ea83.json", "weblink": "/programmi/thegooddoctor" } } ], "track_info": { "id": "", "domain": "raiplay", "platform": "[platform]", "media_type": "", "page_type": "", "editor": "raiplay", "year": "2019", "edit_year": "", "section": "guida tv", "sub_section": "rai 2", "content": "guida tv", "title": "", "channel": "", "date": "2019-09-08", "typology": "", "genres": [], "sub_genres": [], "program_title": "", "program_typology": "", "program_genres": [], "program_sub_genres": [], "edition": "", "season": "", "episode_number": "", "episode_title": "", "form": "", "listaDateMo": [], "dfp": {} }}`
|
||||
const result = parser({ content,date }).map(p => {
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-05-03T19:40:00.000Z',
|
||||
stop: '2022-05-03T20:30:00.000Z',
|
||||
title: 'The Good Doctor S3E5 - La prima volta',
|
||||
description:
|
||||
"Shaun affronta il suo primo intervento. Il caso si rivela complicato e, nonostante Shaun abbia un'idea geniale, sarà Andrews a portare a termine l'operazione.",
|
||||
season: "3",
|
||||
episode: "5",
|
||||
icon: 'https://www.raiplay.it/dl/img/2020/03/09/1583748471860_dddddd.jpg'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `{"events":[],"total":0}`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
19
sites/raiplay.it/raiplay.it_it.channels.xml
Normal file
19
sites/raiplay.it/raiplay.it_it.channels.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="raiplay.it">
|
||||
<channels>
|
||||
<channel lang="it" xmltv_id="Rai1.it" site_id="rai-1">Rai 1</channel>
|
||||
<channel lang="it" xmltv_id="Rai2.it" site_id="rai-2">Rai 2</channel>
|
||||
<channel lang="it" xmltv_id="Rai3.it" site_id="rai-3">Rai 3</channel>
|
||||
<channel lang="it" xmltv_id="Rai4.it" site_id="rai-4">Rai 4</channel>
|
||||
<channel lang="it" xmltv_id="Rai5.it" site_id="rai-5">Rai 5</channel>
|
||||
<channel lang="it" xmltv_id="RaiMovie.it" site_id="rai-movie">Rai Movie</channel>
|
||||
<channel lang="it" xmltv_id="RaiPremium.it" site_id="rai-premium">Rai Premium</channel>
|
||||
<channel lang="it" xmltv_id="RaiGulp.it" site_id="rai-gulp">Rai Gulp</channel>
|
||||
<channel lang="it" xmltv_id="RaiYoyo.it" site_id="rai-yoyo">Rai Yoyo</channel>
|
||||
<channel lang="it" xmltv_id="RaiStoria.it" site_id="rai-storia">Rai Storia</channel>
|
||||
<channel lang="it" xmltv_id="RaiScuola.it" site_id="rai-scuola">Rai Scuola</channel>
|
||||
<channel lang="it" xmltv_id="RaiNews24.it" site_id="rai-news-24">Rai News 24</channel>
|
||||
<channel lang="it" xmltv_id="RaiSportPlusHD.it" site_id="rai-sport-piu-hd">Rai Sport + HD</channel>
|
||||
<channel lang="it" xmltv_id="RaiSport.it" site_id="rai-sport">Rai Sport</channel>
|
||||
</channels>
|
||||
</site>
|
Loading…
Add table
Add a link
Reference in a new issue