mirror of
https://github.com/iptv-org/epg
synced 2026-05-11 03:47:02 -04:00
73 lines
1.7 KiB
JavaScript
73 lines
1.7 KiB
JavaScript
const dayjs = require('dayjs')
|
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
|
|
dayjs.extend(customParseFormat)
|
|
|
|
module.exports = {
|
|
site: 'tvplus.com.tr',
|
|
days: 2,
|
|
url: 'https://izmaottvsc14.tvplus.com.tr:33207/EPG/JSON/PlayBillList',
|
|
request: {
|
|
method: 'POST',
|
|
headers: {
|
|
cookie: 'JSESSIONID=05DH3LSUA0W04YMLSYEWK3TRYY1QMBMY;'
|
|
},
|
|
data({ channel, date }) {
|
|
return {
|
|
type: '2',
|
|
channelid: channel.site_id,
|
|
begintime: date.format('YYYYMMDDHHmmss'),
|
|
endtime: date.add(1, 'd').format('YYYYMMDDHHmmss'),
|
|
isFillProgram: 1
|
|
}
|
|
},
|
|
cache: {
|
|
ttl: 24 * 60 * 60 * 1000 // 1 day
|
|
}
|
|
},
|
|
parser({ content }) {
|
|
const programs = []
|
|
|
|
const items = parseItems(content)
|
|
|
|
items.forEach(schedule => {
|
|
programs.push({
|
|
title: schedule.name,
|
|
description: schedule.introduce,
|
|
category: schedule.genres,
|
|
icon: parseIcon(schedule),
|
|
image: parseImage(schedule),
|
|
start: parseTime(schedule.starttime),
|
|
stop: parseTime(schedule.endtime)
|
|
})
|
|
})
|
|
|
|
return programs
|
|
}
|
|
}
|
|
|
|
function parseTime(time) {
|
|
return dayjs(time, 'YYYY-MM-DD HH:mm:ss [UTC]Z')
|
|
}
|
|
|
|
function parseImage(schedule) {
|
|
return schedule?.picture?.still || null
|
|
}
|
|
|
|
function parseIcon(schedule) {
|
|
if (typeof schedule?.picture?.icon !== 'string') return null
|
|
|
|
return schedule.picture.icon.split(',')[0]
|
|
}
|
|
|
|
function parseItems(content) {
|
|
try {
|
|
const data = JSON.parse(content)
|
|
if (!data || !Array.isArray(data.playbilllist)) return []
|
|
|
|
return data.playbilllist
|
|
} catch {
|
|
return []
|
|
}
|
|
}
|