I FIGURED OUT A WORKAROUND!!! Its silly, but it works...
basically you can do this with system events and the MiniPlayer...
tell application "System Events"
tell its process "Music"
try
click menu item "Add to Library" of menu "Song" of menu bar 1
on error
keystroke "m" using {command down, shift down}
delay 1
click menu item "Add to Library" of menu "Song" of menu bar 1
keystroke "m" using {command down, shift down}
end try
end tell
end tell
So the background for this is I have a rate/add song to playlist function which, as we all know, doesn't work when you're playing from a URL track. I have hotkeys setup through BTT to rate [⌥ + 1-5] or add to a playlist [⌥ + z] which brings up a menu to add to.
Basically, my code now checks if the song is in my library via search function:
tell application "Music"
set searchResults to {}
set cname to ctrack's name as text
set cartist to ctrack's artist as text
set calbum to ctrack's album as text
try
set searchResults to (every track of playlist "Library" whose name contains cname and artist contains cartist and album contains calbum)
end try
end tell
return searchResults
end checkInLibrary
If it's not in my library, it adds it through the first function (which is probably very inefficient) then performs the rate/add to playlist functions.
I REALLY HOPE THIS HELPS SOMEONE because I have been going through all of the hoops to make this work...
Topic:
Media Technologies
SubTopic:
General
Tags: