Hi Folks. I’m new to the game and started using Engine DJ with my SC Live 4 (which I love). I have around 350 tracks in my collection right now. I needed a way to create a set of mutually exclusive playlists that do not contain any tracks from each other. I couldn’t figure out how to do this in Engine DJ so I wrote some sqlite queries and wrapped them in zsh (I’m on mac) that help me build playlists. These scripts read the engine DJ library database directly from disk (outside of Engine DJ).
I’m posting them here for you to peruse, crib, and ridicule. YMMV, caveat emptor, no guarantee expressed or written, not DJ advice.
Find tracks that are NOT already in a set of existing exclusive playlists, and thus are eligible for inclusion:
#!/bin/zsh
# the script takes one argument which allows you to provide a
# Camelot key to search for (or not)
# no argument returns all eligible tracks
# an argument of '8' returns both 8A and 8B tracks
# an argument of '8A' returns only 8A tracks
SEARCHKEY=“${1}%”
sqlite3 --readonly “/Users/YOURUSERHERE/Music/Engine Library/Database2/m.db” <<EOF
.headers on.mode column.width 40 40 40 40 40
SELECT
t.artist,
SUBSTR(t.title, 1,32) AS short_title,
SUBSTR(t.album, 1,32) as short_album,
t.genre,
CASE t.key
WHEN 1 THEN ‘8A’ WHEN 2 THEN ‘9B’ WHEN 3 THEN ‘9A’ WHEN 4 THEN ‘10B’
WHEN 5 THEN ‘10A’ WHEN 6 THEN ‘11B’ WHEN 7 THEN ‘11A’ WHEN 8 THEN ‘12B’
WHEN 9 THEN ‘12A’ WHEN 10 THEN ‘1B’ WHEN 11 THEN ‘1A’ WHEN 12 THEN ‘2B’
WHEN 13 THEN ‘2A’ WHEN 14 THEN ‘3B’ WHEN 15 THEN ‘3A’ WHEN 16 THEN ‘4B’
WHEN 17 THEN ‘4A’ WHEN 18 THEN ‘5B’ WHEN 19 THEN ‘5A’ WHEN 20 THEN ‘6B’
WHEN 21 THEN ‘6A’ WHEN 22 THEN ‘7B’ WHEN 23 THEN ‘7A’ WHEN 24 THEN ‘8B’
ELSE ‘Unknown’
END AS camelot_key
FROM Track t
JOIN PlaylistEntity pe ON t.id = pe.trackId
JOIN Playlist p ON pe.listId = p.id
WHERE p.title = ‘All DJ Music’ -- A playlist containing all tracks
AND camelot_key LIKE “$SEARCHKEY”
AND t.id NOT IN (SELECT pe2.trackId
FROM PlaylistEntity pe2
JOIN Playlist p2 ON pe2.listId = p2.id
WHERE p2.title IN (‘Set 1’, ‘Set 2’, ‘Set 3’, ‘Set 4’, ‘Set 5’, ‘Mix7’) -- The tracks from playlists to AVOID adding again
)
ORDER by t.key ASC;
EOF
And here’s one to find tracks accidentally put in multiple playlists:
#!/bin/zsh
sqlite3 --readonly “/Users/YOURUSERHERE/Music/Engine Library/Database2/m.db” <<EOF
.headers on.mode column
SELECT
t.artist,
t.title,
GROUP_CONCAT(p.title, ’ | ') AS found_in_playlists,
COUNT(*) as appearance_count
FROM Track t
JOIN PlaylistEntity pe ON t.id = pe.trackId
JOIN Playlist p ON pe.listId = p.id
WHERE p.title IN (‘Set 1’, ‘Set 2’, ‘Set 443’, ‘Set 4’, ‘Set 5’) -- Your set of exclusive playlists
GROUP BY t.id
HAVING COUNT(*) > 1
ORDER BY appearance_count DESC;
EOF