Fixed a mess I wrote last night. Ahahaha!

This commit is contained in:
Alexander Andreev 2021-02-17 19:34:44 +04:00
parent d3b298ee8b
commit de78ad5d31
Signed by: Arav
GPG Key ID: 610DF2574456329F
1 changed files with 17 additions and 16 deletions

View File

@ -10,22 +10,23 @@ const config = require("./config");
const util = require("./util");
async function getRadioStatus() {
let status = await fetch('http://radio.home/status-json.xsl').then(r => r.json())
.catch(() => {
return {
server_start_iso8601: "n/a",
server_start_date: "n/a",
song: "n/a",
listener_peak: "n/a",
listeners: "n/a"
}
});
return {
server_start_iso8601: status.icestats.server_start_iso8601,
server_start_date: util.datetime(status.icestats.server_start_iso8601, util.post_date_format),
song: `${status.icestats.source.artist} - ${status.icestats.source.title}`,
listener_peak: status.icestats.source.listener_peak,
listeners: status.icestats.source.listeners
try {
let status = await fetch('http://radio.home/status-json.xsl').then(r => r.json());
return {
server_start_iso8601: status.icestats.server_start_iso8601,
server_start_date: util.datetime(status.icestats.server_start_iso8601, util.post_date_format),
song: `${status.icestats.source.artist} - ${status.icestats.source.title}`,
listener_peak: status.icestats.source.listener_peak,
listeners: status.icestats.source.listeners
}
} catch {
return {
server_start_iso8601: "n/a",
server_start_date: "n/a",
song: "n/a",
listener_peak: "n/a",
listeners: "n/a"
}
}
}