This project is made for my Prompt Engineering class at BME. With this project I've learned the basics of Spotipy, Openai python libraries and I'm also learning how to use Github, and Github Copilot efficiently for my studies.
This file is an example of the apis.py where you can store the API keys, and scopes for the program.
The program supports the default Spotify time intervals. The long_term option will get every listening data made since the creation of the Spotify account. Approximately medium_term uses the last 6 months data, and short_term only uses the last four weeks.
Right now the program supports the GPT 3.5 Turbo and GPT4 model. The first model is better when we want more genereric, more deterministic answers, it mostly generates popular music made before 2021-22. However the GPT 4 is better at generating less popular music, and give as more verbose results. I advise using the GPT 4 model.
For playlist picture generation, the program uses DALL-E 2.0. This can make the process much slower, and more expensive, so by default this function is turned off, but with the checkbox, this can be changed.
Important
Using Picture Generation is 0.016$, which is a lot higher than just generating the playlist. if we'd like to generate a lot of playlists, I advise not to generate pictures.
The comments are colored by "Better Comments" VSCode extension. The "#?" comments are descriptions for variables. The "#!" comments are warnings, and the "#TODO" comments mark unfinished methods and files.
I've used Github Copilot, for the comments, Docstrings and to generate more readable codes. I also used it to debug, and it helped me to learn Pythons TKinter library.
Used Python libraries are:
- openai
- spotipy
- webbrowser (Opening Spoitfy Authorization page)
- time (Delaying when uploading playlist picture)
- base64 (Image decoding)
- tkinter (UI)
- os (for file management)
- Pillow (PIL) (for image optimization)
The versions of these libraries are in the dependency graph (or here)
The Python version used for developing: Python 3.11.3
The logo was created with Onlinelogomaker,and the pictures are made with DALL-E 2.0.
The Spotify API doesn't really support images with big size for playlists, so the generated images, are optimized with PIL, for upload stability. Also the picture upload needs to be delayed, so the Spotify has enough time to create the playlist.
The photos in this directory show the app in runtime, and the resulting playlist in spotify.
Make sure the required dependencies are downloaded, and run the main.py. When the program used for the first time, it needs authentication, which will pop up instantly in the default browser of the user. The app was developed using Python 3.11.3, so I advise using this version for running. Don't forget to rename example_apis.py to apis.py and put it in the sources folder.