Fixed a mess I wrote last night. Ahahaha!
This commit is contained in:
parent
d3b298ee8b
commit
de78ad5d31
33
radio.js
33
radio.js
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user