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

Adds recommendation by artist #6

Merged
merged 4 commits into from
Sep 10, 2024
Merged

Adds recommendation by artist #6

merged 4 commits into from
Sep 10, 2024

Conversation

skycube19
Copy link
Collaborator

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 last Spicetify.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.

@anishsudini anishsudini self-requested a review September 10, 2024 18:13
Copy link
Collaborator

@anishsudini anishsudini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Go ahead and merge.

@skycube19 skycube19 merged commit 68a01ed into main Sep 10, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants