now: retrieve latest track/album added to musicthread

This commit is contained in:
John Bowdre 2024-05-01 13:15:05 -05:00
parent a4a96dae3d
commit 2b25bc9c32
2 changed files with 13 additions and 4 deletions

4
now.md
View file

@ -40,7 +40,7 @@
- [Futuristic Violence and Fancy Suits](https://johndiesattheend.com/futuristic-violence-fancy-suits/) by Jason Pargin (aka David Wong) {book} - [Futuristic Violence and Fancy Suits](https://johndiesattheend.com/futuristic-violence-fancy-suits/) by Jason Pargin (aka David Wong) {book}
- [The Gentleman](https://imdb.com/title/tt13210838/) {display} - [The Gentleman](https://imdb.com/title/tt13210838/) {display}
- [Baldur's Gate 3](https://store.steampowered.com/app/1086940/Baldurs_Gate_3/) {gamepad} - [Baldur's Gate 3](https://store.steampowered.com/app/1086940/Baldurs_Gate_3/) {gamepad}
- [Homicide (feat. Eminem)](https://musicthread.app/link/2fWfoHJysUL8LlwyiIZoo6Vjmck) by Logic {headphones} - <span id="now-playing">Silence</span> {headphones}
<br> <br>
@ -61,4 +61,4 @@

View file

@ -121,5 +121,14 @@ fetch(wx_endpoint)
document.getElementsByClassName('fa-arrow-right-long')[0].classList = CLASS_MAP_PRESS[pressureTrend]; document.getElementsByClassName('fa-arrow-right-long')[0].classList = CLASS_MAP_PRESS[pressureTrend];
}); });
</script> </script>
<script>
// retrieves latest link from a musicthread thread and displays it on the page
const musicthread = 'https://musicthread.app/api/v0/thread/2aVjZUocjk96LELFbV5JvJjm14v';
fetch(musicthread)
.then(res => res.json())
.then(function(res){
let nowPlaying = res.links[0];
document.getElementById('now-playing').innerHTML = "<a href='" + nowPlaying.page_url + "'>" + nowPlaying.title + "</a> by " + nowPlaying.artist;
});
</script>