Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot is playing the wrong song when playing a Spotify playlist #137

Open
mrwalters1988 opened this issue Sep 3, 2020 · 10 comments
Open

Bot is playing the wrong song when playing a Spotify playlist #137

mrwalters1988 opened this issue Sep 3, 2020 · 10 comments

Comments

@mrwalters1988
Copy link

Hey all,
Ran this command: $botify play $spotify $list $own PlaylistName

however it seems that every other song is the incorrect song.

The queue seems to list them properly, or as songs that exist in the queue. For instance, of the songs below, Dirty Laundry is played, but the wrong version. The Fugue is instead Sunshine by Squashy Nice, so completely different. Viices is also some overlay. Pixel Dust is played correctly though.

Previous
| The Fugue by Dj T-Rock & Squashy Nice - 04:14
Current
| Dirty Laundry - Heavy Load by Laura Silberberg, Skratch Bastid, Afiara Quartet - 02:53 / 05:06
Next
| Viices (Instrumental) by Made in Heights, Sabzi - 03:50
| Pixel Dust by Hat Films - 04:43

The only reasonable reason I could think of for this is that Botify is, on the back end, not playing the spotify playlist, but is instead grabbing metadata from the playlist, searching for the song, and finding the wrong one.

@robinfriedli
Copy link
Owner

The only reasonable reason I could think of for this is that Botify is, on the back end, not playing the spotify playlist, but is instead grabbing metadata from the playlist, searching for the song, and finding the wrong one.

That's probably exactly what's happening. Since Spotify does not allow third party applications to stream tracks they are looked up and streamed from YouTube instead.

I presume you're using botify 1 (so either the master branch or any release branch). The branch development/v2.0 features an improvement of the algorithm for net.robinfriedli.botify.audio.youtube.YouTubeService#redirectSpotify which generally yields better results in my experience if you want to give that a try, the migration to v2 is pretty big though. If you do give that a try, mind that the old results are still stored by the spotify_redirect_index table and those entries are only refreshed once every 4 weeks by the RefreshSpotifyRedirectIndicesTask cron job since those lookups are expensive in terms of quota usage and time, so you might want to clear that table. Though botify 1 was already accurate most of the time for me, depends what you play.

Else you could lookup those tracks on youtube or some other supported source manually and create a botify playlist based on that.

@DDarkInferno
Copy link

That's probably exactly what's happening. Since Spotify does not allow third party applications to stream tracks they are looked up and streamed from YouTube instead.

I was doing some research and it seems like they do now, just not really sure how it works. If you take a look at the popular music bot, Rythm, they are able to play the exact same song from spotify. Would be really really cool if you were able to add that feature to this bot.

@robinfriedli
Copy link
Owner

No, it's definitely not possible and if Rythm streamed directly from Spotify they would have been taken down and sued by Spotify. Spotify obviously does not legally allow third party applications to stream their content without requiring an athorized Spotify account per user undercutting their entire business. Spotify makes sure no one can create software that distributes their licensed content while evading their monetization policies. The only way to stream content from Spotify is through their Web Playback SDK which works with Encrypted Media Extensions. Other than that there is no way to receive Spotify content for a third party application, much less manipulate and redestribute the raw audio output.

Besides, Rythm has the exact same issue as Botify. I've tried it out for 5 minutes and the first audio book track played completely different audio. The only difference seems to be that the YouTube lookup seems more reliable compared to botify 1, haven't compared it to botify 2 yet.

@DDarkInferno
Copy link

Yup, sorry about that, you're right. When I thought Rythm could do it, I looked into those same articles, the EME player and the github issue and was surprised that Rythm could do it. The way I was testing the Rythm bot was I tried to play a song that was on spotify but not on youtube, and I thought I found one, but I wasn't checking youtube properly. Sorry about that. I appreciate your response though.

@salocinyeet
Copy link

The only way you could prob make it play from Spotify is that if you can put Client Secret and Client Key and self host the bot. That is prob the only way. The people who host Botify can't really tell you give us your Client Secret and Client Key. Because why would you trust them with your spotify account and plus it would be very expensive to store all those secrets and you don't know if the data is breached.

@robinfriedli
Copy link
Owner

You mean the Client Secret for the Web API client? Why wouldn't it work then and why would that have to be provided by the end user? The problem is the Web API can simply not be used to stream any music other than fetching the URL for song previews (which is what the $preview argument does). It is only intended for metadata. Logging in to Spotify is not the problem, botify can do that already to specifically find items in the user's library.

@robinfriedli
Copy link
Owner

I have now backported the improved spotify redirection algorithm from botify 2 to botify 1.6 (#145). Note that the old results are still stored by the spotify_redirect_index table, so you either have to wait for the RefreshSpotifyRedirectIndicesTask to update all indices, this task runs every day at 3 AM and updates all indices that haven't been updated in 4 weeks, or you could just clear the contents of this table if you're hosting your own instance.

@CaitlinTheAwesome
Copy link

CaitlinTheAwesome commented Mar 19, 2021

Going to preface this with: I don't actually code, please excuse my ignorance if this is not how any of this works / if this suggestion is super complicated to implement, but...

If I'm understanding correctly, it looks at the tracklist on Spotify, then goes to youtube and finds videos, and saves that data in a table for future reference? Is there maybe a way to add a "flag as incorrect track" button or command for the currently playing track, that will tell it to go check youtube for the next result for that song and try that one instead (or that would make it clear the table entry for that one track and try pulling it from youtube again)?

I'm running into this issue quite a lot on my D&D playlists, I suspect there's something in the code that will say, if result 1 has 200k views and result 3 has 1.5M views, choose result 3? (In this example scenario, result 1 is the correct song and the rest are different songs as it's not popular enough to have anyone else upload it besides the creator lol)

@robinfriedli
Copy link
Owner

Yeah I though about a similar feature where you can even manually specify the correct YouTube video but with both implementations the issue is that it could easily be abused. It's not quite as bad when you can't explicitly define the video but even then you could just flag the result as incorrect a few times until the remaining results are terrible. One thing I could do is requiring that the new or manually set result still receives a certain minimum score when applying the algorithm but that would still allow users to deliberately worsen the result and on the other hand might reject valid suggestions. It might be a feature that could be activated for self-hosters but I'm not sure if I'll ever enable something like that on the public instance.

@Amara97-sysz
Copy link

The Spotify app itself will queue wrong songs sometime. You can try to download Spotfy music offline to get the offline playback so that you can stay away from this kind of issue. Try some third-party tools like Tunelf Spotify Music Converter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants