Update format.js

This commit is contained in:
Aleksandr Statciuk 2021-08-10 05:47:12 +03:00
parent aebe50b3d1
commit a51cb33c19
1 changed files with 14 additions and 8 deletions

View File

@ -68,13 +68,9 @@ async function updatePlaylist(playlist) {
await checker await checker
.checkStream(channel.data) .checkStream(channel.data)
.then(result => { .then(result => {
if (result.status.ok || result.status.reason.includes('timed out')) { if (config.status) updateStatus(channel, result.status)
if (config.status) updateStatus(channel, null) if (config.resolution && result.status.ok)
if (config.resolution) updateResolution(channel, result.status.metadata) updateResolution(channel, result.status.metadata)
} else {
if (config.debug) log.print(` ERR: ${channel.url} (${result.status.reason})\n`)
if (config.status) updateStatus(channel, 'Offline')
}
}) })
.catch(err => { .catch(err => {
if (config.debug) log.print(` ERR: ${channel.url} (${err.message})\n`) if (config.debug) log.print(` ERR: ${channel.url} (${err.message})\n`)
@ -107,7 +103,17 @@ function addMissingData(channel) {
} }
function updateStatus(channel, status) { function updateStatus(channel, status) {
channel.status = status if (status.ok) {
channel.status = null
} else if (status.reason.includes('timed out')) {
// nothing
} else if (status.reason.includes('403')) {
channel.status = 'Geo-blocked'
if (config.debug) log.print(` ERR: ${channel.url} (${status.reason})\n`)
} else {
channel.status = 'Offline'
if (config.debug) log.print(` ERR: ${channel.url} (${status.reason})\n`)
}
} }
function updateResolution(channel, metadata) { function updateResolution(channel, metadata) {