I am trying to make an AppleScript that automatically adds the current track that I am listening to on Apple Music to my library.
What I have done so far is set the option "Add songs to Library when adding to playlist" to true and then used the following AppleScript code below:
tell application "iTunes"
duplicate current track to playlist "New Songs"
end tell
What happens is it adds the song to the playlist and then it is automatically removed from the playlist and it is not added to my library.
When I add the song to the playlist manually, the track stays in the playlist and gets added to my Library.
How am I to get ScriptEditor to save the current track to my library?
Best Answer
I had the same question today. I don't know AppleScript (first time using it was to make this) so this code is probably very inefficient syntax-wise, but didn't want to risk breaking it by refactoring.
It turns out the only way to add a song to the library in every scenario using AppleScript is to force the application to go into the mini player and then use the "Add to Library" button in the menu bar. You can remove the mini player part of the script if you don't need this script to work with songs that aren't in playlists (e.g a radio).