mirror of
https://github.com/Radiquum/radiquum.github.io.git
synced 2025-04-05 07:44:33 +00:00
23 lines
629 B
JavaScript
23 lines
629 B
JavaScript
function updatePlayingTrack() {
|
|
const trackName = document.getElementById("track-name");
|
|
|
|
fetch("https://lastfm-last-played.biancarosa.com.br/radiquum/latest-song")
|
|
.then((res) => {
|
|
if (!res.ok) {
|
|
throw new Error("Error Fetching Data");
|
|
}
|
|
return res.json();
|
|
})
|
|
.then((data) => {
|
|
trackName.innerHTML = `"${data.track.artist['#text']} - ${data.track.name}"`;
|
|
})
|
|
.catch((err) => {
|
|
trackName.innerHTML = "\"ERROR: last.fm is not reachable\"";
|
|
console.log(err);
|
|
});
|
|
}
|
|
|
|
window.onload = () => {
|
|
updatePlayingTrack();
|
|
setInterval(updatePlayingTrack, 360000);
|
|
}
|