Just-Some-Bots / MusicBot

:musical_note: The original MusicBot for Discord (formerly SexualRhinoceros/MusicBot)
https://just-some-bots.github.io/MusicBot/
MIT License
3.12k stars 2.35k forks source link

Spotify playlists take time time to fetch, rendering !clear kinda useless. #2375

Closed BgueC6595 closed 7 months ago

BgueC6595 commented 9 months ago

What went wrong?

Maybe this should qualify as a feature request, I'm not sure. Tested on the dev branch (latest commit).

Spotify playlists take a while to be cached by the bot; it takes a couple seconds for each individual song to be put into the queue.

The issue arises when someone with permissions wants to clear the queue of this playlist. It effectively becomes impossible without restarting the bot or without waiting several minutes for the songs to be cached. This is because e.g. if 5 songs have been put into the queue, when someone uses !clear the bot will clear the queue BUT it will also keep adding new songs to the queue (songs that were unfetched at the time). Only way to stop the bot is to restart it.

I imagine the ideal solution would be to make !clear cancel any pending attempts to fetch songs from playlists.

How do we reproduce this?

1) On a bot instance with Spotify credentials enabled, use !play [spotify playlist URL] in which the playlist has multiple songs (more than 5 is fine)

2) (Optional) Once the first song starts playing, observe with !queue that only one or two songs are queued at this moment. Over time more songs will be added; next steps must be taken before the whole playlist is queued (which takes a while anyway)

3) Use !clear in an attempt to clear the queue

4) Observe that while the queue at the time was cleared, this doesn't stop the bot from fetching more songs from the playlist that weren't queued at the time

Which version of the bot are you using?

I am using the "dev" branch

Which operating system are you using?

Ubuntu 18.04 or higher

Just checking...

BabyBoySnow commented 9 months ago

The delay is because we can't directly grab anything from Spotify, we have to grab the meta data (author, and track name) then get it from YouTube.

The reason it only shows 1-2 songs at first is because the rest of the playlist is being downloaded amd added. (You can measure roughly how fast by using the shuffle play, it's only on the dev branch as I haven't found a way to download the playlist entirely, then shuffle, then play. Currently it'll play a few songs in the correct order before the playlist is downloaded and then shuffle. Not exactly ideal.)

I do agree that this is something to be looked into but will call it low priority as I would argue that not many people tend to queue a playlist then immediately try to clear it. I think this is more similar to the request for an undo command. Which I also agree might be a good command but haven't had the time to look into it yet.

itsTheFae commented 9 months ago

The patch in PR #2378 is not the most comprehensive, but it should avoid this behavior at least for spotify playlists and albums. I welcome feedback on it, if you're willing to test it out @BgueC6595