Anyone know if there's away to heart/love/favorite a song in the new iTunes via applescript? Basically I want the ability to heart a song from Apple Music without switching back to iTunes.
3 Answers
I wrote a pretty hacky script that does the job for Apple Music tracks. It right clicks on the app icon in the dock, and selects the first option in the menu.
set current_app to current application
activate application "Dock"
tell application "System Events"
tell process "Dock"
set frontmost to true
activate
tell list 1
perform action "AXShowMenu" of UI element "iTunes"
delay 0.01
repeat 1 times -- move down one menu item to the 'love' option
key code 125 -- down arrow
end repeat
delay 0.1 -- 0.01 was too fast
repeat 2 times
key code 36 -- return key
end repeat
end tell
end tell
end tell
activate current_app
(Based on this answer)
Again, this is super-hacky, but it works for me when I'm listening via "For You", which is the only time I usually "love" tracks.
This is the script I use. It toggles the loved status of the current track.
tell application "iTunes"
if loved of current track is true then
set loved of current track to false
else
set loved of current track to true
end if
end tell
It also works for Apple Music; just replace "iTunes" with "Music".
At the moment it doesn't appear to be possible to get or set properties on music played through Apple Music.
However you can heart a track that is stored locally or played from your iCloud Music Library.
tell application "iTunes"
set loved of current track to true
end tell
-
Yeah thats my problem it works for songs downloaded to your music library. Apparently a radar has been field openradar.me/21674162 Commented Jul 25, 2015 at 17:25
-
Yup. You can see Doug Adams of "Doug's AppleScripts for iTunes" talking about it here too. dougscripts.com/itunes/2015/07/… Hopefully this is something that will appear in a minor update soon. Commented Jul 25, 2015 at 17:28