Skip to content

A go implementation of a new shuffle for Spotify.

License

Notifications You must be signed in to change notification settings

syeo66/go-shufflify

Repository files navigation

Go Shufflify

"Go Shufflify" is a web application that integrates with the Spotify API to provide a personalized music queue.

Features

  • User Authentication: Authenticate users via Spotify and manage sessions.
  • Queue Management: Automatically manages the music queue based on user preferences and active playlists.

Project Structure

  • server.go: Entry point for the application.
  • types/: Contains all the data structures used across the application.
  • lib/: Utility functions and common library code.
  • data/: Functions for interacting with the Spotify API and the database.
  • routes/: HTTP route handlers for various endpoints.

Getting Started

Prerequisites

  • Go (1.22.5 or later)
  • Spotify Developer Account with Client ID and Client Secret

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/go-shufflify.git
cd go-shufflify
  1. Install the required Go packages:
go mod tidy
  1. Set up your environment variables:

Create a .env file in the root directory with the following content:

SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SESSION_KEY=your_session_key # A really (!) random key, use 'uuid' or anything else generating random strings
PORT=3333
DB_FILE=./shufflify.db
  1. Start the application
./start_server.sh

This will create the shufflify.db file and set up the necessary tables.

Running the Application

Start the server:

./start_server.sh

Open your browser and navigate to http://localhost:3333/.

Disallowing new users

To disallow new user signups, set DiSALLOW_NEW_USERS to true in the .env file.

Usage

  • Login: Navigate to /login and log in with your Spotify account.
  • Queue Management: The application will automatically manage your music queue based on your preferences when 'Shuffle' is enabled.

Known Issues

Currently the Spotify API returns always 20 items in the queue. If there are not 20 items it just repeats the same items until the 20 items are filled up. This makes it hard to determine the real amount of tracks in the queue. Thus the shuffle works best if you only start playing a track from a Single before Go Shufflify takes over.

See https://community.spotify.com/t5/Spotify-for-Developers/Spotify-Web-API-Queue-endpoint-needs-polish/td-p/5493505

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an issue for any bugs or feature requests.

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add new feature')
  5. Push to the branch (git push origin feature-branch)
  6. Create a new Pull Request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements


Happy shuffling! 🎶