Merge pull request #778 from mcastellaneta/master

Add support for sub_title, url, date, credits
This commit is contained in:
Aleksandr Statciuk 2022-05-08 12:51:50 +03:00 committed by GitHub
commit 46d305f39a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 3 deletions

View file

@ -22,12 +22,24 @@ async function main() {
category: program.category || null, category: program.category || null,
season: program.season || null, season: program.season || null,
episode: program.episode || null, episode: program.episode || null,
url: program.url || null,
icon: program.icon || null, icon: program.icon || null,
channel: program.channel, channel: program.channel,
sub_title: program.sub_title || null,
date: program.date || null,
lang: program.lang, lang: program.lang,
start: program.start, start: program.start,
stop: program.stop, stop: program.stop,
stop: program.stop, director: program.director || null,
actor: program.actor || null,
writer: program.writer || null,
adapter: program.adapter || null,
producer: program.producer || null,
composer: program.composer || null,
editor: program.editor || null,
presenter: program.presenter || null,
commentator: program.commentator || null,
guest: program.guest || null,
site: item.channel.site, site: item.channel.site,
_qid: result._qid _qid: result._qid
} }

View file

@ -32,6 +32,8 @@ module.exports = {
description: item.description, description: item.description,
season: item.season || null, season: item.season || null,
episode: item.episode || null, episode: item.episode || null,
sub_title : item['episode_title'] || null,
url : parseURL(item),
start, start,
stop, stop,
icon: parseIcon(item) icon: parseIcon(item)
@ -47,3 +49,14 @@ function parseIcon(item) {
return cover = item.image ? `https://www.raiplay.it${item.image}` : null return cover = item.image ? `https://www.raiplay.it${item.image}` : null
} }
function parseURL(item) {
let url = null
if(item.weblink){
url = `https://www.raiplay.it${item.weblink}`
}
if(item.event_weblink){
url = `https://www.raiplay.it${item.event_weblink}`
}
return url
}

View file

@ -20,7 +20,7 @@ it('can generate valid url', () => {
}) })
it('can parse response', () => { 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 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 => { const result = parser({ content,date }).map(p => {
return p return p
}) })
@ -34,7 +34,9 @@ it('can parse response', () => {
"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.", "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", season: "3",
episode: "5", episode: "5",
icon: 'https://www.raiplay.it/dl/img/2020/03/09/1583748471860_dddddd.jpg' sub_title: "La prima volta",
icon: 'https://www.raiplay.it/dl/img/2020/03/09/1583748471860_dddddd.jpg',
url: 'https://www.raiplay.it/dirette/rai2/The-Good-Doctor-S3E5---La-prima-volta-2f81030d-803b-456a-9ea5-40233234fd9d.html'
} }
]) ])
}) })