As part of another script I’m trying to write, I’m trying to get the playlist (name or reference) of the track currently selected in Apple Music and set it as a variable. Here are some things I’ve tried:
tell application "Music"
set selectedTrack to selection
set selectedPlaylist to (get playlist id of selection)
-- set selectedPlaylist to (get playlist of selection)
-- set selectedPlaylist to (get user playlist id of selection)
-- set selectedPlaylist to (get user playlist of selection)
log selectedPlaylist
end tell
Hoping it’s quite simple for someone who actually knows what they’re doing
First, selection is a list, so you’d get its item 1.
Then, looking at the application dictionary (did you do that?) I see that file track inherits from track > item.
And item has a property container.
So:
tell application "iTunes"
set selectedTrack to item 1 of (get selection)
-->file track id 3243 of user playlist id 2813 of source id 66 of application "iTunes"
set pl to container of selectedTrack
--> user playlist id 2813 of source id 66 of application "iTunes"
properties of pl
--> {class:user playlist, id:2813, index:2, name:"Muziek", persistent ID:"038DE205151B8651", duration:178155, size:2.9401292144E+10, time:"2:01:29:15", visible:true, special kind:Music, loved:false, disliked:false, smart:true, shared:false, genius:false}
end tell
This should work when you change ‘iTunes’ to ‘Music’. If it doesn’t you should log a bug with Apple.
Can do?