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 dayjs = require('dayjs')
|
||||||
const jsdom = require('jsdom')
|
|
||||||
const { JSDOM } = jsdom
|
|
||||||
|
|
||||||
require('dayjs/locale/ro')
|
|
||||||
dayjs.locale('ro')
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
request: {
|
request: {
|
||||||
|
@ -11,15 +6,18 @@ module.exports = {
|
||||||
},
|
},
|
||||||
site: 'programetv.ro',
|
site: 'programetv.ro',
|
||||||
url: function ({ date, channel }) {
|
url: function ({ date, channel }) {
|
||||||
const diff = dayjs().diff(date, 'd')
|
const daysOfWeek = {
|
||||||
let day
|
0: 'duminica',
|
||||||
if (diff === 0) {
|
1: 'luni',
|
||||||
day = 'azi'
|
2: 'marti',
|
||||||
} else {
|
3: 'ieri',
|
||||||
day = date.format('ddd').toLowerCase()
|
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 }) {
|
logo({ content }) {
|
||||||
const data = parseContent(content)
|
const data = parseContent(content)
|
||||||
|
@ -29,30 +27,36 @@ module.exports = {
|
||||||
parser: function ({ content }) {
|
parser: function ({ content }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
const data = parseContent(content)
|
const data = parseContent(content)
|
||||||
if (!data) return programs
|
if (!data || !data.shows) return programs
|
||||||
if (data) {
|
const items = data.shows
|
||||||
programs = data.shows.map(i => {
|
items.forEach(item => {
|
||||||
let title = i.title
|
let title = item.title
|
||||||
if (i.season) title += ` Sez.${i.season}`
|
if (item.season) title += ` Sez.${item.season}`
|
||||||
if (i.episode) title += ` Ep.${i.episode}`
|
if (item.episode) title += ` Ep.${item.episode}`
|
||||||
return {
|
programs.push({
|
||||||
title,
|
title,
|
||||||
description: i.desc,
|
description: item.desc,
|
||||||
category: i.categories[0],
|
category: item.categories,
|
||||||
start: i.start,
|
start: parseStart(item).toString(),
|
||||||
stop: i.stop,
|
stop: parseStop(item).toString(),
|
||||||
icon: i.icon
|
icon: item.icon
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseContent(content) {
|
function parseStart(item) {
|
||||||
const pageData = content.match(/var pageData = (.*);/i)
|
return dayjs(item.start).utc()
|
||||||
if (!pageData && !pageData[1]) return null
|
}
|
||||||
|
|
||||||
return JSON.parse(pageData[1], null, 2)
|
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