Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 🚀 The Ultimate AI Playlist Setup Guide
- We are creating three files: one for the initial data export/setup (plex_music_exporter.py), one for the final playlist creation (ai_playlist_builder.py), and one simple shell script for daily use (new_playlist.sh).
- Step 1: Initial Setup & Dependencies
- 1 SSH into your server and go to your working directory.
- 2 Activate your environment (if it's not already active): Bash source plex_ai_env/bin/activate
- 3
- 4 Install/Update Dependencies (This ensures you have the latest stable tools): Bash pip install plexapi google-genai pydantic
- 5 (Note: If you didn't install screen yet, run sudo apt install screen now to handle background running.)
- Step 2: Create the Data Exporter (plex_music_exporter.py)
- This script runs weekly to refresh your entire library and upload it to Gemini's storage, saving you API costs.
- Create the file and paste the code below. Remember to replace all {INSERT YOUR...} placeholders.
- https://colab.research.google.com/drive/15gqZz7wr2MVRYIwcbGnHG-v-8LmXoMD6?usp=sharing
- 🏃 First Run (The Long Wait)
- 1 Save the file.
- 2 Run this script in a screen session (if you have thousands of tracks) to perform the initial large upload: Bash screen -S exporter-init
- 3 source plex_ai_env/bin/activate
- 4 python3 plex_music_exporter.py
- 5 # Press Ctrl + A, then D to detach and safely close your Mac.
- 6
- 7
- Step 3: Create the Playlist Builder (ai_playlist_builder.py)
- This script handles the AI communication, the retry loop for guaranteed length, and the tricky Plex search.
- Create the file and paste the code below:
- https://colab.research.google.com/drive/1qkHFoAzDYppkI1T97n7RLwGUQgnnRWQ6?usp=sharing
- Step 4: 💾 File: new_playlist.sh (Usability Interface)
- Create the file named new_playlist.sh and paste the following code:
- #!/bin/bash
- # 1. Activate the Python virtual environment
- # IMPORTANT: Replace /home/user/ with your actual user path (e.g., /home/chris/)
- source /home/user/plex_ai_env/bin/activate
- # 2. Ask the user for the playlist prompt
- echo "--------------------------------------------------------"
- echo " AI PLAYLIST CREATOR"
- echo "--------------------------------------------------------"
- echo "Enter your request (e.g., '90s Grunge with female vocals'):"
- read -r USER_PROMPT
- # 3. Ask the user for the max track count
- echo "Enter MAX number of tracks (e.g., 10 or 45):"
- read -r MAX_TRACKS
- # 4. Run the Python script with BOTH arguments
- # IMPORTANT: Replace /home/user/ with your actual user path (e.g., /home/chris/)
- /home/user/plex_ai_env/bin/python /home/user/ai_playlist_builder.py "$USER_PROMPT" "$MAX_TRACKS"
- # 5. Deactivate environment
- deactivate
- Final Steps to Run the System:
- 1 Save the file (Ctrl + O, Enter, Ctrl + X).
- 2 Make the script executable: Bash chmod +x new_playlist.sh
- 3 3. **Run your new interface:**
- 4 ```bash
- 5 ./new_playlist.sh
- 6
- 7
- You now have the full, end-to-end stable system!
Advertisement
Add Comment
Please, Sign In to add comment