misc.anonradio: forgot one
This commit is contained in:
parent
6efea6a824
commit
d145ff2940
1 changed files with 19 additions and 9 deletions
|
@ -275,9 +275,18 @@ anonradio.helpText = "aNONradio.net schedule";
|
||||||
anonradio.callback = async function () {
|
anonradio.callback = async function () {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
const playing = await fetch("https://anonradio.net/playing").then((res) =>
|
let playing;
|
||||||
|
try {
|
||||||
|
playing = await fetch("https://anonradio.net/playing").then((res) =>
|
||||||
res.text()
|
res.text()
|
||||||
);
|
);
|
||||||
|
} catch (err) {
|
||||||
|
try {
|
||||||
|
playing = await fetch("http://anonradio.net/playing").then((res) =>
|
||||||
|
res.text()
|
||||||
|
);
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
let schedule;
|
let schedule;
|
||||||
try {
|
try {
|
||||||
schedule = await fetch("https://anonradio.net/schedule/").then((res) =>
|
schedule = await fetch("https://anonradio.net/schedule/").then((res) =>
|
||||||
|
@ -291,7 +300,13 @@ anonradio.callback = async function () {
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!schedule) return "Failed to fetch schedule.";
|
if (!playing || !schedule) return "Failed to fetch schedule.";
|
||||||
|
|
||||||
|
const icecast = await fetch("http://anonradio.net:8010/status-json.xsl")
|
||||||
|
.then((res) => res.text())
|
||||||
|
.then((data) =>
|
||||||
|
JSON.parse(data.replace(/"title": - ,/g, '"title":" - ",'))
|
||||||
|
);
|
||||||
|
|
||||||
let lines = schedule.split("\n");
|
let lines = schedule.split("\n");
|
||||||
lines = lines.slice(4, lines.length - 2);
|
lines = lines.slice(4, lines.length - 2);
|
||||||
|
@ -373,11 +388,6 @@ anonradio.callback = async function () {
|
||||||
|
|
||||||
let openmicTime = "";
|
let openmicTime = "";
|
||||||
if (liveNow.id == "openmic") {
|
if (liveNow.id == "openmic") {
|
||||||
const icecast = await fetch("http://anonradio.net:8010/status-json.xsl")
|
|
||||||
.then((res) => res.text())
|
|
||||||
.then((data) =>
|
|
||||||
JSON.parse(data.replace(/"title": - ,/g, '"title":" - ",'))
|
|
||||||
);
|
|
||||||
const streamData = icecast.icestats.source.find(
|
const streamData = icecast.icestats.source.find(
|
||||||
(src) => src.listenurl == "http://anonradio.net:8010/openmic"
|
(src) => src.listenurl == "http://anonradio.net:8010/openmic"
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue