Created
October 28, 2023 09:00
-
-
Save sydrawat01/d446389f6c034fa441f54aceca93768e to your computer and use it in GitHub Desktop.
Apple music script
This file contains hidden or 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
| #!/usr/bin/env osascript | |
| # Returns the current playing song in Spotify for OSX | |
| tell application "Music" | |
| if it is running then | |
| if player state is playing then | |
| set track_name to name of current track | |
| set artist_name to artist of current track | |
| if artist_name > 0 | |
| # If the track has an artist set and is therefore most likely a song rather than an advert | |
| set t to "♫ " & artist_name & " - " & track_name | |
| if length of t > 35 | |
| text 1 thru 35 of t & "..." | |
| else | |
| "♫ " & artist_name & " - " & track_name | |
| end if | |
| else | |
| # If the track doesn't have an artist set and is therefore most likely an advert rather than a song | |
| "~ " & track_name | |
| end if | |
| end if | |
| end if | |
| end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment