mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update programetv.ro.config.js
This commit is contained in:
parent
f1bbcf5935
commit
2416ca5f19
1 changed files with 36 additions and 32 deletions
|
@ -1,9 +1,4 @@
|
|||
const dayjs = require('dayjs')
|
||||
const jsdom = require('jsdom')
|
||||
const { JSDOM } = jsdom
|
||||
|
||||
require('dayjs/locale/ro')
|
||||
dayjs.locale('ro')
|
||||
|
||||
module.exports = {
|
||||
request: {
|
||||
|
@ -11,15 +6,18 @@ module.exports = {
|
|||
},
|
||||
site: 'programetv.ro',
|
||||
url: function ({ date, channel }) {
|
||||
const diff = dayjs().diff(date, 'd')
|
||||
let day
|
||||
if (diff === 0) {
|
||||
day = 'azi'
|
||||
} else {
|
||||
day = date.format('ddd').toLowerCase()
|
||||
const daysOfWeek = {
|
||||
0: 'duminica',
|
||||
1: 'luni',
|
||||
2: 'marti',
|
||||
3: 'ieri',
|
||||
4: 'azi',
|
||||
5: 'vineri',
|
||||
6: 'sambata'
|
||||
}
|
||||
const day = date.day()
|
||||
|
||||
return `https://www.programetv.ro/post/${channel.site_id}/${day}/`
|
||||
return `https://www.programetv.ro/post/${channel.site_id}/${daysOfWeek[day]}/`
|
||||
},
|
||||
logo({ content }) {
|
||||
const data = parseContent(content)
|
||||
|
@ -29,30 +27,36 @@ module.exports = {
|
|||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const data = parseContent(content)
|
||||
if (!data) return programs
|
||||
if (data) {
|
||||
programs = data.shows.map(i => {
|
||||
let title = i.title
|
||||
if (i.season) title += ` Sez.${i.season}`
|
||||
if (i.episode) title += ` Ep.${i.episode}`
|
||||
return {
|
||||
if (!data || !data.shows) return programs
|
||||
const items = data.shows
|
||||
items.forEach(item => {
|
||||
let title = item.title
|
||||
if (item.season) title += ` Sez.${item.season}`
|
||||
if (item.episode) title += ` Ep.${item.episode}`
|
||||
programs.push({
|
||||
title,
|
||||
description: i.desc,
|
||||
category: i.categories[0],
|
||||
start: i.start,
|
||||
stop: i.stop,
|
||||
icon: i.icon
|
||||
}
|
||||
description: item.desc,
|
||||
category: item.categories,
|
||||
start: parseStart(item).toString(),
|
||||
stop: parseStop(item).toString(),
|
||||
icon: item.icon
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseContent(content) {
|
||||
const pageData = content.match(/var pageData = (.*);/i)
|
||||
if (!pageData && !pageData[1]) return null
|
||||
|
||||
return JSON.parse(pageData[1], null, 2)
|
||||
function parseStart(item) {
|
||||
return dayjs(item.start).utc()
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs(item.stop).utc()
|
||||
}
|
||||
|
||||
function parseContent(content) {
|
||||
const [_, data] = content.match(/var pageData = ((.|[\r\n])+);\n/) || [null, null]
|
||||
|
||||
return data ? JSON.parse(data) : {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue