mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Create digea.gr.config.js
This commit is contained in:
parent
8e19193621
commit
69159b2cf1
1 changed files with 86 additions and 0 deletions
86
sites/digea.gr/digea.gr.config.js
Normal file
86
sites/digea.gr/digea.gr.config.js
Normal file
|
@ -0,0 +1,86 @@
|
|||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'digea.gr',
|
||||
days: 2,
|
||||
url: 'https://www.digea.gr/el/api/epg/get-events',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
},
|
||||
data({ date }) {
|
||||
const data = new URLSearchParams()
|
||||
data.append('action', 'get_events')
|
||||
data.append('date', date.format('YYYY-M-D'))
|
||||
|
||||
return data
|
||||
}
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
let items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.long_synopsis,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.post(
|
||||
'https://www.digea.gr/el/api/epg/get-channels',
|
||||
new URLSearchParams({
|
||||
action: 'get_chanels',
|
||||
lang: 'el'
|
||||
}),
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
return data.map(channel => {
|
||||
return {
|
||||
lang: 'el',
|
||||
site_id: channel.id,
|
||||
name: channel.name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.actual_time, 'YYYY-MM-DD HH:mm:ss', 'Europe/Athens')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.end_time, 'YYYY-MM-DD HH:mm:ss', 'Europe/Athens')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
try {
|
||||
const data = JSON.parse(content)
|
||||
if (!Array.isArray(data)) return []
|
||||
|
||||
return data.filter(p => p.channel_id === channel.site_id)
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue