Created
August 10, 2023 13:50
-
-
Save detecti1/f7d04129ef9e2b5d4987a9dfcadbdec1 to your computer and use it in GitHub Desktop.
Set Loved and add apple music track to library via applescript
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
tell application "Music" | |
set loved of current track to true | |
set songTitle to name of current track | |
set songAlbum to album of current track | |
set songInfo to songTitle & " - " & songAlbum | |
try | |
duplicate current track to source 1 | |
on error | |
try | |
tell application "System Events" | |
tell its process "Music" | |
try | |
click menu item "添加到资料库" of menu "歌曲" of menu bar 1 | |
on error | |
keystroke "m" using {command down, shift down} | |
delay 1 | |
click menu item "添加到资料库" of menu "歌曲" of menu bar 1 | |
keystroke "m" using {command down, shift down} | |
end try | |
end tell | |
end tell | |
on error errorMsg number errorNum | |
display notification "Failed to add to library: " & songInfo & errorMsg | |
error errorMsg number errorNum | |
end try | |
end try | |
display notification "Loved song: " & songInfo | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment