Shuffle playlist, fetch list of artists, fetch list of genres #36
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.
I have added new endpoints.
The first addition is for shuffling a playlist, either by name or playlistId.
The second addition is the beginning of some other new features I'm hoping to add. Now there are endpoints for getting a list of all Album Artists, as well as a list of getting all Genres. Initially when the server starts, if a cache has not been created each for Artists and Genres, the Album Artist names will all be fetched from iTunes and written to /tmp/artists.txt. The same is true for Genres, but to /tmp/genres.txt. These cache files will now be read when the server starts in the future, and loaded into memory otherwise, for when the endpoints are hit. The 'update' endpoints for Artists and Genres will trigger doing a fresh metadata grab from iTunes to update the respective cache file.
Ultimately, the Artists and Genres endpoints were added to assist in new endpoints I'd like to work on next for shuffling a specific artist or genre. This would allow a client application to display all genres/artists and the user could pick from them.
I'm a total beginner with JS and am still learning with AppleScript, so if there are obvious refactors I missed, I won't be surprised. That being said, hopefully the code doesn't look too bad!