Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds dynamic recommendations by artists.
I also had to add logic for both the songs and artists to refresh a song's or artist's position in the queue if it is played again while it is still in the queue. This means for example if you play the same song again within the next 4 songs, it now actually gets refreshed to appear as a "new" song.
Similar logic was implemented for the artists, except it is more complicated since there are potentially multiple artists per song and the order that these artists appear in the
Spicetify.Player.data.item.artists
array can differ. So I basically checked if every artist appears within the lastSpicetify.Player.data.item.artists.length
positions of the queue, and if it doesn't that means you need to refresh the positions. I did this in a naive way, it's not at all optimized but our array size is so small I think it doesn't matter at all.I also added a small button to allow changing between recommending by songs or artists.
Adding recommendations by genres is going to be more complicated because apparently Spotify doesn't have genres for each song(?). So, we have to get genres by artists. BUT, all genres are not allowed to be used to generate recommendations. We would have to first get all the available genres from the
/recommendations/available-genre-seeds
endpoint and then get all the genres attached to each artist and check if it falls in that list. If it does, then only can we add the genre to the queue. I am planning on implementing this in a future PR.