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

Shuffle playlist, fetch list of artists, fetch list of genres #36

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

HenryGlendening
Copy link

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!

@HenryGlendening
Copy link
Author

That makes sense. My ultimate goal is to build a basic app to control HomeKit, which would include the ability to browse a list of artists/genres/playlists and pick one to play/shuffle. This would allow my other family members to change the music on our shared iTunes library.

Also, I have some Hue dimmer switches and want them to control the music for their respective area of my home. I'd like each press of the On button to 'change the radio station' (change the music to the next playlist in a pre-defined queue rotation of playlists). The code I added should make this easy with HomeKit automations.

Here's a homebridge plugin to set up the API routes (for specific playlists or artists) are HomeKit devices - https://github.com/Supereg/homebridge-http-switch

…Playing playlist due to higher efficiency than by using JXA
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