Getting iTunes Artwork

I’ve got the following code which works fine in Script Editor:

[code]on run
tell application “System Events”
set the process_flag to (exists process “iTunes”)
end tell
if the process_flag is false then
ignoring application responses
tell application “iTunes” to launch
end ignoring
end if

tell application "iTunes"
	try
		set lib_ref to first library playlist
		set track_ref to first track of lib_ref
		tell track_ref
			if artworks exists then
				set artworkData to (data of artwork 1)
				return artworkData
			end if
			return null
		end tell
	end try
end tell
return null

end run[/code]

Then the code in Xojo always returns null:

[code]Dim xAppleScript As NSAppleScriptMBS
Dim dError As Dictionary
Dim xEvent As NSAppleEventDescriptorMBS

xAppleScript = New NSAppleScriptMBS(AppleScriptTunesArtwork)
Call xAppleScript.Compile()
xEvent = xAppleScript.Execute(dError)

break[/code]

Any ideas how to get iTunes song artwork?

Isnt there an entitlement you need for AppleScripting other apps ?

https://stackoverflow.com/questions/21924932/how-to-run-an-applescript-from-a-sandboxed-application-on-a-mac-os-x

Yes, I am using:

<?xml version="1.0" encoding="UTF-8"?> com.apple.security.app-sandbox com.apple.security.personal-information.calendars com.apple.security.personal-information.addressbook com.apple.security.device.camera com.apple.security.files.bookmarks.app-scope com.apple.security.files.bookmarks.document-scope com.apple.security.files.bookmarks.collection-scope com.apple.security.files.user-selected.read-write com.apple.security.network.client com.apple.security.automation.apple-events com.apple.security.inherit com.apple.security.assets.music.read-only com.apple.security.scripting-targets com.apple.iTunes com.apple.iTunes.library.read com.apple.iTunes.user-interface com.apple.iTunes.playback com.apple.security.print

If you’re running Mojave, you also need to add the new “Privacy” bullshit to your plist file. Which can be done in App Wrapper 3.9.

If you have access to the file; you could try seeing if you can get the artwork via MDS or even reading the file’s meta data.

Yeah I’ve done that too but manually. No go. Not sure what’s up. I’ve just switched to media library MBs class instead

MLMediaObjectMBS ArtworkImage property may help.