Fixed a mess I wrote last night. Ahahaha!
This commit is contained in:
parent
d3b298ee8b
commit
de78ad5d31
19
radio.js
19
radio.js
@ -10,8 +10,16 @@ const config = require("./config");
|
|||||||
const util = require("./util");
|
const util = require("./util");
|
||||||
|
|
||||||
async function getRadioStatus() {
|
async function getRadioStatus() {
|
||||||
let status = await fetch('http://radio.home/status-json.xsl').then(r => r.json())
|
try {
|
||||||
.catch(() => {
|
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 {
|
return {
|
||||||
server_start_iso8601: "n/a",
|
server_start_iso8601: "n/a",
|
||||||
server_start_date: "n/a",
|
server_start_date: "n/a",
|
||||||
@ -19,13 +27,6 @@ async function getRadioStatus() {
|
|||||||
listener_peak: "n/a",
|
listener_peak: "n/a",
|
||||||
listeners: "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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user