Update mts.rs.config.js

This commit is contained in:
Aleksandr Statciuk 2021-11-21 22:49:10 +03:00
parent bbbb109586
commit 59aeea2ada

View file

@ -27,15 +27,13 @@ module.exports = {
const data = parseContent(content, channel) const data = parseContent(content, channel)
const items = parseItems(data) const items = parseItems(data)
items.forEach(item => { items.forEach(item => {
const start = parseStart(item)
const stop = parseStop(item)
programs.push({ programs.push({
title: item.title, title: item.title,
category: item.category, category: item.category,
description: item.description, description: item.description,
icon: item.image, icon: item.image,
start: start.toJSON(), start: parseStart(item),
stop: stop.toJSON() stop: parseStop(item)
}) })
}) })
@ -45,8 +43,10 @@ module.exports = {
function parseContent(content, channel) { function parseContent(content, channel) {
const [_, site_id] = channel.site_id.split('#') const [_, site_id] = channel.site_id.split('#')
if (!content) return null let data
const data = JSON.parse(content) try {
data = JSON.parse(content)
} catch (e) {}
if (!data || !data.channels || !data.channels.length) return null if (!data || !data.channels || !data.channels.length) return null
return data.channels.find(c => c.id === site_id) || null return data.channels.find(c => c.id === site_id) || null