As the Now playing widget struggles to get the album artwork if you're streaming a song which is not in your library and I did not find a way to get the now playing information from the mini player (which would be awesome because I could also control the music currently plying on the HomePod), I wrote the following script to download the album artwork as jpg:
-- get the raw bytes of the artwork into a var tell application "Music" to tell artwork 1 of current track set srcBytes to raw data -- figure out the proper file extension if format is «class PNG » then set ext to ".png" else set ext to ".jpg" end if end tell -- get the filename to ~/Desktop/cover.ext set fileName to ((((path to application support folder from user domain) as text) & "BetterTouchTool:" as text) & "music_cover" & ext) -- write to file set outFile to open for access file fileName with write permission -- truncate the file set eof outFile to 0 -- write the image bytes to the file write srcBytes to outFile close access outFile return fileName
Now the thing is, in order to display it in the Touch Bar I need it to get converted into base64. Any idea how this could be achieved?
Thanks for any help!