2021-03-27 14:26:48 +03:00
|
|
|
const dayjs = require('dayjs')
|
2022-09-21 22:23:45 +01:00
|
|
|
const utc = require('dayjs/plugin/utc')
|
|
|
|
|
|
|
|
|
|
dayjs.extend(utc)
|
2021-03-27 14:26:48 +03:00
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
site: 'programetv.ro',
|
|
|
|
|
url: function ({ date, channel }) {
|
2021-11-05 07:37:14 +03:00
|
|
|
const daysOfWeek = {
|
|
|
|
|
0: 'duminica',
|
|
|
|
|
1: 'luni',
|
|
|
|
|
2: 'marti',
|
2022-06-15 18:31:26 +01:00
|
|
|
3: 'miercuri',
|
|
|
|
|
4: 'joi',
|
2021-11-05 07:37:14 +03:00
|
|
|
5: 'vineri',
|
|
|
|
|
6: 'sambata'
|
2021-03-27 14:26:48 +03:00
|
|
|
}
|
2021-11-05 07:37:14 +03:00
|
|
|
const day = date.day()
|
2021-03-27 14:26:48 +03:00
|
|
|
|
2021-11-05 07:37:14 +03:00
|
|
|
return `https://www.programetv.ro/post/${channel.site_id}/${daysOfWeek[day]}/`
|
2021-03-27 14:26:48 +03:00
|
|
|
},
|
2022-09-21 21:57:09 +01:00
|
|
|
parser: function ({ content, channel }) {
|
2021-03-27 14:26:48 +03:00
|
|
|
let programs = []
|
|
|
|
|
const data = parseContent(content)
|
2021-11-05 07:37:14 +03:00
|
|
|
if (!data || !data.shows) return programs
|
|
|
|
|
const items = data.shows
|
|
|
|
|
items.forEach(item => {
|
|
|
|
|
programs.push({
|
2022-09-22 17:14:10 +01:00
|
|
|
title: item.title,
|
|
|
|
|
sub_title: item.titleOriginal,
|
2022-09-21 21:57:09 +01:00
|
|
|
description: item.desc || item.obs,
|
2021-11-05 07:37:14 +03:00
|
|
|
category: item.categories,
|
2022-09-21 21:57:09 +01:00
|
|
|
season: item.season || null,
|
|
|
|
|
episode: item.episode || null,
|
|
|
|
|
start: parseStart(item),
|
|
|
|
|
stop: parseStop(item),
|
|
|
|
|
url: item.url || null,
|
|
|
|
|
date: item.date,
|
|
|
|
|
rating: parseRating(item),
|
|
|
|
|
directors: parseDirector(item),
|
|
|
|
|
actors: parseActor(item),
|
2021-11-05 07:37:14 +03:00
|
|
|
icon: item.icon
|
2021-03-27 14:26:48 +03:00
|
|
|
})
|
2021-11-05 07:37:14 +03:00
|
|
|
})
|
2021-03-27 14:26:48 +03:00
|
|
|
|
|
|
|
|
return programs
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-05 07:37:14 +03:00
|
|
|
function parseStart(item) {
|
2022-09-21 22:23:45 +01:00
|
|
|
return dayjs(item.start).toJSON()
|
2021-11-05 07:37:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseStop(item) {
|
2022-09-21 22:23:45 +01:00
|
|
|
return dayjs(item.stop).toJSON()
|
2021-11-05 07:37:14 +03:00
|
|
|
}
|
|
|
|
|
|
2021-03-27 14:26:48 +03:00
|
|
|
function parseContent(content) {
|
2021-11-05 07:37:14 +03:00
|
|
|
const [_, data] = content.match(/var pageData = ((.|[\r\n])+);\n/) || [null, null]
|
2021-03-27 14:26:48 +03:00
|
|
|
|
2021-11-05 07:37:14 +03:00
|
|
|
return data ? JSON.parse(data) : {}
|
2021-03-27 14:26:48 +03:00
|
|
|
}
|
2022-09-21 21:57:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
function parseDirector(item) {
|
|
|
|
|
return item.credits && item.credits.director ? item.credits.director : null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseActor(item) {
|
|
|
|
|
return item.credits && item.credits.actor ? item.credits.actor : null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseRating(item) {
|
|
|
|
|
return item.rating
|
|
|
|
|
? {
|
|
|
|
|
system: 'CNC',
|
|
|
|
|
value: item.rating.toUpperCase()
|
|
|
|
|
}
|
|
|
|
|
: null
|
|
|
|
|
}
|