added stuff

main
Wiki 2024-12-10 12:58:28 +00:00
parent bc34be80ed
commit 5e46426e61
4 changed files with 123 additions and 0 deletions

5
index.html Normal file
View File

@ -0,0 +1,5 @@
<script src="./main.js"></script>
<body>listening to: <n></n></body>
<img id="trackIcon">
<a id="track"></a>

25
main.js Normal file
View File

@ -0,0 +1,25 @@
async function getData() {
const url = "http://localhost:3000/userrecent?userName=sussyenby&limit=1";
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const json = await response.json();
try{ if (json.recenttracks.track[0]["@attr"].nowplaying) {
console.log(json.recenttracks.track[0].name)
console.log(json.recenttracks.track[0].url)
console.log(json.recenttracks.track[0].image[0]["#text"])
document.getElementById("track").innerHTML = json.recenttracks.track[0].name
document.getElementById("track").setAttribute("href", json.recenttracks.track[0].url)
document.getElementById("trackIcon").setAttribute("src", json.recenttracks.track[0].image[0]["#text"])
return;
} else {}
} catch(error) {}
} catch (error) {
console.error(error.message);
}
}
getData()

6
package-lock.json generated Normal file
View File

@ -0,0 +1,6 @@
{
"name": "Test1",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}

87
response.json Normal file
View File

@ -0,0 +1,87 @@
{
"success": true,
"json": {
"recenttracks": {
"track": [
{
"artist": {
"mbid": "eb3c021d-e056-42d6-8fad-064205a90527",
"#text": "femtanyl"
},
"streamable": "0",
"image": [
{
"size": "small",
"#text": "https://lastfm.freetls.fastly.net/i/u/34s/27ef895634fd7051a12d12b48f0d6734.jpg"
},
{
"size": "medium",
"#text": "https://lastfm.freetls.fastly.net/i/u/64s/27ef895634fd7051a12d12b48f0d6734.jpg"
},
{
"size": "large",
"#text": "https://lastfm.freetls.fastly.net/i/u/174s/27ef895634fd7051a12d12b48f0d6734.jpg"
},
{
"size": "extralarge",
"#text": "https://lastfm.freetls.fastly.net/i/u/300x300/27ef895634fd7051a12d12b48f0d6734.jpg"
}
],
"mbid": "3be21971-70e9-48da-9b30-50156c88f8b6",
"album": {
"mbid": "9ea39f16-6dc0-4deb-bcc1-23b145a33615",
"#text": "ACT RIGHT"
},
"name": "ACT RIGHT",
"@attr": {
"nowplaying": "true"
},
"url": "https://www.last.fm/music/femtanyl/_/ACT+RIGHT"
},
{
"artist": {
"mbid": "eb3c021d-e056-42d6-8fad-064205a90527",
"#text": "femtanyl"
},
"streamable": "0",
"image": [
{
"size": "small",
"#text": "https://lastfm.freetls.fastly.net/i/u/34s/0c0a4f6f6e95736514314450bd586a38.jpg"
},
{
"size": "medium",
"#text": "https://lastfm.freetls.fastly.net/i/u/64s/0c0a4f6f6e95736514314450bd586a38.jpg"
},
{
"size": "large",
"#text": "https://lastfm.freetls.fastly.net/i/u/174s/0c0a4f6f6e95736514314450bd586a38.jpg"
},
{
"size": "extralarge",
"#text": "https://lastfm.freetls.fastly.net/i/u/300x300/0c0a4f6f6e95736514314450bd586a38.jpg"
}
],
"mbid": "3d11e1f6-10c2-4b49-a3a8-55395ad3e504",
"album": {
"mbid": "",
"#text": "And I'm Gone"
},
"name": "AND I'M GONE",
"url": "https://www.last.fm/music/femtanyl/_/AND+I%27M+GONE",
"date": {
"uts": "1733685416",
"#text": "08 Dec 2024, 19:16"
}
}
],
"@attr": {
"user": "sussyenby",
"totalPages": "9936",
"page": "1",
"perPage": "1",
"total": "9936"
}
}
}
}