mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update tv.mail.ru.config.js
This commit is contained in:
parent
ece68edc61
commit
418fa169ee
1 changed files with 21 additions and 22 deletions
|
@ -16,28 +16,29 @@ module.exports = {
|
||||||
},
|
},
|
||||||
logo({ content }) {
|
logo({ content }) {
|
||||||
const json = JSON.parse(content)
|
const json = JSON.parse(content)
|
||||||
if (json.status !== 'OK') return null
|
if (!json || !Array.isArray(json.schedule)) return null
|
||||||
|
|
||||||
return json.schedule[0].channel.pic_url_64
|
return json.schedule[0] && json.schedule[0].channel
|
||||||
|
? json.schedule[0].channel.pic_url_128
|
||||||
|
: null
|
||||||
},
|
},
|
||||||
parser({ content, date }) {
|
parser({ content, date }) {
|
||||||
let PM = false
|
|
||||||
const programs = []
|
const programs = []
|
||||||
const items = parseItems(content)
|
const items = parseItems(content)
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const title = parseTitle(item)
|
const prev = programs[programs.length - 1]
|
||||||
const category = parseCategory(item)
|
|
||||||
let start = parseStart(item, date)
|
let start = parseStart(item, date)
|
||||||
if (start.hour() > 11) PM = true
|
if (prev) {
|
||||||
if (start.hour() < 12 && PM) start = start.add(1, 'd')
|
if (start.isBefore(prev.start)) {
|
||||||
const stop = start.add(1, 'h')
|
start = start.add(1, 'd')
|
||||||
if (programs.length) {
|
date = date.add(1, 'd')
|
||||||
programs[programs.length - 1].stop = start
|
}
|
||||||
|
prev.stop = start
|
||||||
}
|
}
|
||||||
|
const stop = start.add(1, 'h')
|
||||||
programs.push({
|
programs.push({
|
||||||
title,
|
title: item.name,
|
||||||
category,
|
category: parseCategory(item),
|
||||||
start,
|
start,
|
||||||
stop
|
stop
|
||||||
})
|
})
|
||||||
|
@ -48,13 +49,9 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item, date) {
|
function parseStart(item, date) {
|
||||||
const time = `${date.format('MM/DD/YYYY')} ${item.start}`
|
const dateString = `${date.format('YYYY-MM-DD')} ${item.start}`
|
||||||
|
|
||||||
return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Moscow')
|
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Europe/Moscow')
|
||||||
}
|
|
||||||
|
|
||||||
function parseTitle(item) {
|
|
||||||
return item.name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCategory(item) {
|
function parseCategory(item) {
|
||||||
|
@ -62,24 +59,26 @@ function parseCategory(item) {
|
||||||
1: 'Фильм',
|
1: 'Фильм',
|
||||||
2: 'Сериал',
|
2: 'Сериал',
|
||||||
6: 'Документальное',
|
6: 'Документальное',
|
||||||
|
7: 'Телемагазин',
|
||||||
8: 'Позновательное',
|
8: 'Позновательное',
|
||||||
10: 'Другое',
|
10: 'Другое',
|
||||||
14: 'ТВ-шоу',
|
14: 'ТВ-шоу',
|
||||||
16: 'Досуг,Хобби',
|
16: 'Досуг,Хобби',
|
||||||
17: 'Ток-шоу',
|
17: 'Ток-шоу',
|
||||||
18: 'Юмористическое',
|
18: 'Юмористическое',
|
||||||
|
23: 'Музыка',
|
||||||
24: 'Развлекательное',
|
24: 'Развлекательное',
|
||||||
25: 'Игровое',
|
25: 'Игровое',
|
||||||
26: 'Новости'
|
26: 'Новости'
|
||||||
}
|
}
|
||||||
|
|
||||||
return categories[item.category_id] || null
|
return categories[item.category_id]
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content) {
|
function parseItems(content) {
|
||||||
const json = JSON.parse(content)
|
const json = JSON.parse(content)
|
||||||
if (json.status !== 'OK') return []
|
if (!Array.isArray(json.schedule) || !json.schedule[0]) return []
|
||||||
const event = json.schedule[0].event
|
const event = json.schedule[0].event || []
|
||||||
|
|
||||||
return [...event.past, ...event.current]
|
return [...event.past, ...event.current]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue