Last active
November 10, 2018 17:39
-
-
Save dnicolson/685869ad1ea4740c1cc0dc8eea85584c to your computer and use it in GitHub Desktop.
JXA to add songs to a playlist based on an artist and list of songs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ARTIST = '' | |
let TRACKS = [] | |
const app = Application('iTunes') | |
const destinationPlaylist = app.userPlaylists.whose({name: {_equals: ARTIST}})[0] | |
TRACKS.forEach((name) => { | |
const matchedNames = app.playlists.whose({name: 'Library'})[0].tracks | |
.whose({name: {_equals: name}}) | |
for (let i = 0; i < matchedNames.length; i++) { | |
if (matchedNames[i].artist() === ARTIST) { | |
matchedNames[i].duplicate({to: destinationPlaylist}) | |
TRACKS = TRACKS.filter(n => n !== name) | |
} | |
} | |
}) | |
TRACKS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment