Apple Music playlists default to an auto-generated mosaic of album covers that you can’t customize programmatically. Spotify does this better — each playlist gets a clean 2x2 grid of the first four album covers. I wanted the same thing for Apple Music.

The Problem

Music.app’s scripting dictionary lists artworks as a read-write element on playlists, but make new artwork at playlist returns error -2710. The documented API doesn’t work.

The Workaround

After trying AppleScript, JXA, ScriptingBridge, MusicKit, clipboard automation, and System Events UI scripting, I found one thing that works:

1set data of artwork 1 of p to imgData

It throws “An error of type 1 has occurred.” It also sets the artwork. The command succeeds despite reporting failure.

How It Works

ampart is a Python CLI that:

  1. Fetches all user playlists from Music.app via JXA
  2. For each playlist, finds the first 4 tracks with unique albums and artists
  3. Extracts each track’s album art via AppleScript
  4. Composites them into a 2x2 grid with Pillow
  5. Sets the result as the playlist artwork (ignoring the spurious error)

For playlists with fewer than 4 unique albums, it just uses the first track’s cover.

Example output

Usage

1pip install Pillow
2python3 set_playlist_artwork.py --dry-run  # preview
3python3 set_playlist_artwork.py            # update all playlists

Source on GitHub