TuneCraft is a unique Spotify playlist generator that creates new playlists based on your existing playlists, musical taste, and specified criteria. Designed to help you explore new music while maintaining a familiar sound, TuneCraft ensures that it recommends new songs by checking all your liked songs and songs that exist in your playlists.
The main code is located in the main.py file. Functions for interacting with the Spotify API and generating playlists can be found in the same file.
These instructions will get you a copy of the project up and running on your local machine.
You need to have a machine with Python >= 3.6 and any Bash-based shell (e.g. zsh) installed.
$ python3.10 -V
Python 3.10
$ echo $SHELL
/usr/bin/zshAll the installation steps are being handled by the Makefile.
Then, to create a conda environment, install the requirements, setup the library and run the tests execute the following commands:
$ make create_env
$ conda activate tunecraft
$ make requirementsFirst, make sure you are in the correct virtual environment:
$ conda activate tune_craft
$ which python
/home/<user>/anaconda3/envs/src/bin/pythonConfigure your username (could be fount in your Spotify profile) in .env
Now, in order to run the code you can call the main.py directly.
$ python main.py -h
usage: main.py -u USER_ID [-s SEED_PLAYLIST] [-nt NUMBER_TRACKS] [--new-artists] [--refresh] [-pl -LIST_PLAYLISTS] [-gl LIST-GENRES] [-h HELP] [-g GENRE] [-bpm BPM]
TuneCraft - Spotify Playlist Generator
Optional Arguments:
-u USERNAME --username Configure the account to generate playlist to
-s SEED_PLAYLIST, --seed-playlist SEED_PLAYLIST
The seed playlist ID to generate a new playlist from
-nt NUMBER_TRACKS, --number-tracks NUMBER_TRACKS
Number of tracks in the generated playlist
--new-artists Include only new artists
--refresh Refresh the local database from Spotify
-pl --list-playlists List all your playlists
-gl --list-genres List all genres
-g --genre Include only the input genre
-bpm --bpm Include only tracks with the specified tempo
-h, --help Show this help message and exit
Available Genre: {'genres': ['acoustic', 'afrobeat', 'alt-rock', 'alternative', 'ambient', 'anime', 'black-metal', 'bluegrass', 'blues', 'bossanova', 'brazil', 'breakbeat', 'british', 'cantopop', 'chicago-house', 'children', 'chill', 'classical', 'club', 'comedy', 'country', 'dance', 'dancehall', 'death-metal', 'deep-house', 'detroit-techno', 'disco', 'disney', 'drum-and-bass', 'dub', 'dubstep', 'edm', 'electro', 'electronic', 'emo', 'folk', 'forro', 'french', 'funk', 'garage', 'german', 'gospel', 'goth', 'grindcore', 'groove', 'grunge', 'guitar', 'happy', 'hard-rock', 'hardcore', 'hardstyle', 'heavy-metal', 'hip-hop', 'holidays', 'honky-tonk', 'house', 'idm', 'indian', 'indie', 'indie-pop', 'industrial', 'iranian', 'j-dance', 'j-idol', 'j-pop', 'j-rock', 'jazz', 'k-pop', 'kids', 'latin', 'latino', 'malay', 'mandopop', 'metal', 'metal-misc', 'metalcore', 'minimal-techno', 'movies', 'mpb', 'new-age', 'new-release', 'opera', 'pagode', 'party', 'philippines-opm', 'piano', 'pop', 'pop-film', 'post-dubstep', 'power-pop', 'progressive-house', 'psych-rock', 'punk', 'punk-rock', 'r-n-b', 'rainy-day', 'reggae', 'reggaeton', 'road-trip', 'rock', 'rock-n-roll', 'rockabilly', 'romance', 'sad', 'salsa', 'samba', 'sertanejo', 'show-tunes', 'singer-songwriter', 'ska', 'sleep', 'songwriter', 'soul', 'soundtracks', 'spanish', 'study', 'summer', 'swedish', 'synth-pop', 'tango', 'techno', 'trance', 'trip-hop', 'turkish', 'work-out', 'world-music']}Get all playlists under the user's account and corresponding IDs:
$ python main.py -pl- You should expect something like (before the playlist name is the playlist id):
$ Welcome to Spotify Playlist Generator! Your playlists: 5cvqOBnWyutLDR9gn2qGCP: #RECENT 4kihcTS1QYwAtKjkAtabkP: House 5M9qy5FiKU0wSPZOWglrMO: jazz hiphop
Get all genres collected on Spotify:
$ python main.py -glGenerate a new playlist based on a seed playlist ID with 20 tracks:
$ python main.py -s your_seed_playlist_id -nt 20Generate a new hiphop playlist based on a seed playlist ID with 20 tracks with 70 bpm:
$ python main.py -s your_seed_playlist_id -nt 20 -g hip-hop -bpm 70Generate a new playlist with only new artists:
$ python main.py -s your_seed_playlist_id --new-artistsRefresh the local database and list all your playlists:
$ python main.py --refresh --list-playlists-
Add support for generating playlists based on moods.
-
Implement a web interface for easier user interaction.
-
Improve the playlist generation algorithm for better recommendations.
This project is licensed under the Apache License - see the LICENSE file for details.