kittinan / spotify-github-profile

Show your Spotify playing on your Github profile
https://spotify-github-profile.kittinanx.com/api/login
MIT License
1.5k stars 616 forks source link

Can you possibly add auto refresh? or auto update. #56

Closed unofficialdxnny closed 1 year ago

unofficialdxnny commented 1 year ago

Hello basically as you know when the songs finish unless the page is refreshed the song doesn't update.

Can you add some sort of auto refresh on the element so it automatically updates on new song playing.

Thanks

unofficialdxnny commented 1 year ago

Hey so the reason I wanted to have this was because in my case I am using it for my Website. I decided to get off my ass and actually make a function for it. If you are also using this feature for your site you are welcome.

<img id="Spotify-now-playing" src="https://spotify-github-profile.vercel.app/api/view.svg?uid=ahmeddanial&cover_image=true&theme=novatorem&show_offline=true&background_color=121212&bar_color=f2aa4c&bar_color_cover=false" width="250" alt="Spotify-Down">
Spotify-Down

setInterval(function() {
  var myImageElement = document.getElementById('Spotify-now-playing');
  myImageElement.src = 'https://spotify-github-profile.vercel.app/api/view.svg?uid=ahmeddanial&cover_image=true&theme=novatorem&show_offline=true&background_color=121212&bar_color=f2aa4c&bar_color_cover=false?rand=' + Math.random();
}, 5000);
kittinan commented 1 year ago

It does not work on Github. GitHub always cleans up javascript in an SVG images.

unofficialdxnny commented 1 year ago

It does not work on Github. GitHub always cleans up javascript in an SVG images.

Yes thats true. I was trying to write an answer for people incase they want to use it in their website so i just left a setInterval function in my answer.

For GitHub you have no alternative at the moment other than refresh the browser.