misc.anonradio: add http fallback
This commit is contained in:
parent
5b07c150dc
commit
6efea6a824
1 changed files with 18 additions and 7 deletions
|
@ -278,14 +278,20 @@ anonradio.callback = async function () {
|
||||||
const playing = await fetch("https://anonradio.net/playing").then((res) =>
|
const playing = await fetch("https://anonradio.net/playing").then((res) =>
|
||||||
res.text()
|
res.text()
|
||||||
);
|
);
|
||||||
const schedule = await fetch("https://anonradio.net/schedule/").then((res) =>
|
let schedule;
|
||||||
|
try {
|
||||||
|
schedule = await fetch("https://anonradio.net/schedule/").then((res) =>
|
||||||
res.text()
|
res.text()
|
||||||
);
|
);
|
||||||
const icecast = await fetch("http://anonradio.net:8010/status-json.xsl")
|
} catch (err) {
|
||||||
.then((res) => res.text())
|
try {
|
||||||
.then((data) =>
|
schedule = await fetch("http://anonradio.net/schedule/").then((res) =>
|
||||||
JSON.parse(data.replace(/"title": - ,/g, '"title":" - ",'))
|
res.text()
|
||||||
);
|
);
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!schedule) return "Failed to fetch schedule.";
|
||||||
|
|
||||||
let lines = schedule.split("\n");
|
let lines = schedule.split("\n");
|
||||||
lines = lines.slice(4, lines.length - 2);
|
lines = lines.slice(4, lines.length - 2);
|
||||||
|
@ -367,6 +373,11 @@ 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