|
|
@ -86,11 +86,20 @@ async function updateStreams() {
|
|
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
if (result) {
|
|
|
|
const { error, streams, requests } = result
|
|
|
|
const { error, streams, requests } = result
|
|
|
|
const status = parseStatus(error, item.status)
|
|
|
|
|
|
|
|
const resolution = parseResolution(streams)
|
|
|
|
const resolution = parseResolution(streams)
|
|
|
|
const origin = findOrigin(requests)
|
|
|
|
const origin = findOrigin(requests)
|
|
|
|
|
|
|
|
let status = parseStatus(error)
|
|
|
|
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
if (status) {
|
|
|
|
|
|
|
|
const prevStatus = item.status
|
|
|
|
|
|
|
|
if (prevStatus.code === 'not_247') // not_247 -> * = not_247
|
|
|
|
|
|
|
|
status = item.status
|
|
|
|
|
|
|
|
else if (prevStatus.code === 'geo_blocked') // geo_blocked -> * = geo_blocked
|
|
|
|
|
|
|
|
status = item.status
|
|
|
|
|
|
|
|
else if(prevStatus.code === 'offline' && status.code === 'online') // offline -> online = not_247
|
|
|
|
|
|
|
|
status = statuses['not_247']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stream.set('status', { status })
|
|
|
|
stream.set('status', { status })
|
|
|
|
stream.set('is_broken', { status: stream.get('status') })
|
|
|
|
stream.set('is_broken', { status: stream.get('status') })
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -200,24 +209,9 @@ function parseResolution(streams) {
|
|
|
|
return null
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Mapping Scheme:
|
|
|
|
function parseStatus(error) {
|
|
|
|
// ===============
|
|
|
|
|
|
|
|
// not_247 -> * = not_247
|
|
|
|
|
|
|
|
// geo_blocked -> * = geo_blocked
|
|
|
|
|
|
|
|
// offline -> online = not_247
|
|
|
|
|
|
|
|
// * -> online = online
|
|
|
|
|
|
|
|
// * -> timeout = timeout
|
|
|
|
|
|
|
|
// * -> geo_blocked = geo_blocked
|
|
|
|
|
|
|
|
// * -> offline = offline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function parseStatus(error, prevStatus) {
|
|
|
|
|
|
|
|
if (['not_247', 'geo_blocked'].includes(prevStatus.code)) return null
|
|
|
|
|
|
|
|
if(!error && prevStatus.code === 'offline') return statuses['not_247']
|
|
|
|
|
|
|
|
if(!error) return statuses['online']
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
if (error) {
|
|
|
|
if (['not_247', 'geo_blocked'].includes(prevStatus.code)) {
|
|
|
|
if (error.includes('timed out')) {
|
|
|
|
return prevStatus
|
|
|
|
|
|
|
|
} else if (error.includes('timed out')) {
|
|
|
|
|
|
|
|
return statuses['timeout']
|
|
|
|
return statuses['timeout']
|
|
|
|
} else if (error.includes('403')) {
|
|
|
|
} else if (error.includes('403')) {
|
|
|
|
return statuses['geo_blocked']
|
|
|
|
return statuses['geo_blocked']
|
|
|
@ -225,7 +219,7 @@ function parseStatus(error, prevStatus) {
|
|
|
|
return statuses['offline']
|
|
|
|
return statuses['offline']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null
|
|
|
|
return statuses['online']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function findLogo(id) {
|
|
|
|
function findLogo(id) {
|
|
|
|