Git Product home page Git Product logo

spotifyaienchancer's Introduction

Spotify Playlist Generator with AI Recommendations

90% of this generated by GitHub Copilot, even README ๐Ÿคก

This project is a Spotify playlist generator that uses the Spotify API and Claude GPT to create personalized playlists based on your liked songs and mood. The application fetches your liked songs, sends them to Claude GPT for analysis, and generates playlists with song recommendations tailored to your music taste and current mood.

Features

  • Fetches your liked songs from Spotify
  • Analyzes your music taste using Claude GPT
  • Generates personalized playlists based on your mood (happy, calm, energetic, working)
  • Automatically updates playlists every 10 hours
  • Web interface for easy authentication and playlist generation
  • Current price for Claude GPT around $0.20 for one playlist

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/spotify-playlist-generator.git
    
  2. Install the required dependencies:

    pip install spotipy flask apscheduler Flask-Session
    
  3. Set up your Spotify app credentials:

    • Create a new app on the Spotify Developer Dashboard
    • Set the SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET variables in the code with your app's client ID and client secret
    • Set the SPOTIPY_REDIRECT_URI variable to http://127.0.0.1:5003/callback for local development
    • Don`t forget to add callback url to you Spotify app
    • Until you Spotify app is in development mode, you can only use your own account to authenticate, if you need to add users manually using User Management tab in your Spotify app setting
  4. Set up your Claude GPT API key:

    • Sign up for an API key at Anthropic
    • Set the CLUDE_API_KEY variable in the code with your API key

Usage

  1. Run the application:

    python spotify.py
    
  2. Open your web browser and navigate to http://127.0.0.1:5003

  3. Click on the "Login with Spotify" button to authenticate with your Spotify account

  4. Once authenticated, the application will fetch your liked songs, analyze your music taste, and generate personalized playlists based on your mood

  5. The playlists will be automatically updated and regenerated everyday at 10:00 server time

Methods

  • fetch_liked_tracks(sp, limit): Fetches your liked songs from Spotify up to the specified limit
  • clear_playlist(sp, playlist_id): Clears the specified playlist
  • create_playlist_if_not_exists(sp, user_id, playlist_name): Creates a new playlist with the specified name if it doesn't exist
  • add_tracks_to_playlist(sp, playlist_id, recomendation): Adds tracks to the specified playlist based on the AI recommendations
  • get_ai_recomendations(liked_tracks, mood): Sends your liked songs and mood to Claude GPT and retrieves song recommendations
  • do_job(user_id, user_token): Performs the playlist generation job for a specific user
  • write_to_db(user_id, user_token): Writes user information to the SQLite database
  • check_updates_job(): Checks for users who haven't updated their playlists in the last 10 hours and triggers the playlist generation job

Libraries

  • spotipy: A Python library for the Spotify Web API
  • anthropic: A Python library for the Claude GPT API
  • flask: A lightweight web framework for Python
  • apscheduler: A Python library for scheduling jobs
  • sqlite3: A Python library for working with SQLite databases

Customization

  • Original promt can be found in get_ai_recomendations(liked_tracks, mood)
  • You can change mood preset by changing mood variable in get_ai_recomendations(liked_tracks, mood) calls inside do_job(user_id, user_token) method
  • For example, change recomendation_happy = get_ai_recomendations(tracks, "happy") to recomendation_happy = get_ai_recomendations(tracks, "sad") and it will generate playlist for sad mood

This project is licensed under the MIT License.

spotifyaienchancer's People

Contributors

krakozuy avatar

Watchers

 avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.