🎬 Classify Plex music into smart playlists using Ollama and local LLMs

⚑ 6 views · 🎬 Content Creation & Video

Description

Quick overview

A scheduled workflow that (1) fetches all tracks from a Plex Music library, (2) sends them in batches to a local Ollama LLM for playlist classification, (3) recreates and populates matching Plex playlists.

How it works

  1. Runs weekly on a schedule and queries the Plex server for library sections and the server machine identifier.
  2. Selects the Plex music library section and paginates through the library to collect and normalize all track metadata.
  3. Splits the full track list into batches, builds a classification prompt, and sends each batch to Ollama (/api/generate) to assign every track to one of the predefined playlist names.
  4. Parses and validates the Ollama responses, accumulates an ID-to-playlist map across all batches, and groups track IDs by playlist.
  5. For each playlist group, retrieves existing Plex playlists by name, deletes any matching playlist, and creates a new playlist seeded with the first 50 tracks.
  6. Chunks the remaining track IDs into sets of 50 and appends them to the newly created Plex playlists via the Plex playlists items API.

Setup

  1. Provide a Plex HTTP header credential (including X-Plex-Token) and replace MY_HOST_OR_IP in all Plex HTTP Request nodes with your Plex server address (check the workflow instruction for more details).
  2. Ensure your Plex server is reachable from n8n and that the target library contains a Music section (type β€œartist”) with track items.
  3. Run Ollama on a reachable host, confirm the model name used in the request (for example, gemma2:9b) is installed, and update the Ollama URL (MY_OLLAMA_HOST_OR_IP:11434) to match with your local IP.
  4. Review or adjust the schedule timing and the predefined playlist names in the prompt to match the playlists you want created in Plex.

Requirements

Customization

Additional info

While this template provides an out-of-the-box architecture for exhaustive, 100% coverage music classification using local LLMs (like gemma2:9b or mistral:7b), your final playlist accuracy depends heavily on two factors: ID3 Metadata Quality, Personalized Prompt Tuning.

πŸ”— Nodes Used

HTTP Request, Schedule Trigger

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup