(or: How Groovy plays music from Spotify, Apple Music, Deezer, ...)
When you queue a song from Spotify, or any other proprietary platform, like Apple Music, Deezer, or Tidal, a lot of things happen behind the scenes.
TL;DR: we throw the metadata into YouTube.
Since these platforms don't let us directly stream from them, as opposed to alternatives, like SoundCloud, we found another way to still provide you with music, when you queue a track, playlist, or even artist page from Spotify. But how does it work?
This is a three-step process. For the sake of making an example, we're going to use Spotify throughout this article. Though, this works the same for all other proprietary platforms like Apple Music, Deezer, or Tidal.
Step 1: Getting the track data from Spotify
When you play a link, and we detect that it's from Spotify, our Spotify Integration queries the Spotify API, i.e. asks Spotify what's behind that link. For a track, that might be title and artist, while for an album or a playlist it's a list of those.
Step 2: Throwing all of that into YouTube
While Spotify doesn't let you directly stream audio, YouTube does! So we just query YouTube using the metadata (fancy name for the whole set of artist, title, etc.) and some special secret sauce and get the closest equivalent to the track you entered.
Step 3: Playing that in your voice channel
Now, this is the part that overlaps with any normal YouTube track. Taking the audio, process it if you have a volume or any audio effects set, and then handing it to Discord for you to listen to.
This step is also the reason our volume command is limited to premium: without it, we wouldn't need to process the audio (which takes like 100x the resources of just piping it into Discord). Volume 100 gives you the original audio exactly the way we get it from YouTube (yeah, sadly that's usually very loud).
Now that you know how we play from Spotify, why not try it out? Just -play and link from Spotify or visit this article for more help.