itunes-api icon indicating copy to clipboard operation
itunes-api copied to clipboard

Add macOS Catalina compatibility

Open DrMachin opened this issue 5 years ago • 4 comments

This will add compatibility for macOS Catalina and Apple Music while still keeping iTunes compatibly.

The only breaking change is to the now playing artwork as I could not come up with a clean way of keeping it compatible with iTunes.

DrMachin avatar Jul 28 '20 17:07 DrMachin

What exactly is the broken change with the artwork?

maddox avatar Jul 28 '20 17:07 maddox

I changed tell application "iTunes" to tell application "Music" which will make it work with Apple Music but not iTunes. I couldn't find a good way to check or failover to the correct application.

DrMachin avatar Jul 28 '20 17:07 DrMachin

Ahhh I see. Could you check the version of macOS before the command, and do either or?

maddox avatar Jul 28 '20 17:07 maddox

I've tried a few things. Checking os version, app/file exists, and wrapping the whole thing in a try block and running the on error. keep running into Expected end of line but found identifier.

Basically since the iTunes (or Music) library doesn't exist anymore it fails when it sees it.

The closest I got was doing this:

tell me
	try
		get application id "com.apple.Music"
		set pathToPlayer to "Music.app"
	on error
		get application id "com.apple.iTunes"
		set pathToPlayer to "iTunes.app"
	end try
	using terms from application "Music"
		tell application pathToPlayer
			try
				set aTrack to the current track
				set aArtwork to data of artwork 1 of aTrack
				my write_to_file(aArtwork, "/tmp/currently-playing.jpg", false)
			on error
				log "error getting info"
			end try
		end tell
	end using terms from
end tell

But since I need to wrap it in using terms from application to make it work, I'm back to square one.

DrMachin avatar Jul 28 '20 19:07 DrMachin