Last active
February 16, 2021 03:22
-
-
Save gmanley/750426aa91097aeef3aee5a73a1f5a04 to your computer and use it in GitHub Desktop.
This file contains 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
(function() { | |
var currentApp = Application.currentApplication() | |
currentApp.includeStandardAdditions = true | |
if (currentApp.systemInfo().systemVersion >= "10.15") { | |
var musicApp = Application("Music") | |
} else { | |
var musicApp = Application("iTunes") | |
} | |
var markTrack = (track, shouldLove) => { | |
if (shouldLove) { | |
track.loved = shouldLove | |
return "Loved: " + track.name() | |
} else { | |
track.loved = shouldLove | |
return "Unloved: " + track.name() | |
} | |
} | |
var shouldLove = "{query}" == "true" | |
if (currentApp.name == musicApp.name) { | |
var selection = musicApp.selection() | |
if (selection.length > 0) { | |
selection.forEach(track => { | |
markTrack(track, shouldLove) | |
}) | |
return "Loved: " + selection.map(t => t.name()).join(" & ") | |
} else { | |
return markTrack(musicApp.currentTrack(), shouldLove) | |
} | |
} else { | |
return markTrack(musicApp.currentTrack(), shouldLove) | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment