Search code examples
applescriptspotifyscripting-bridge

Spotify AppleScript strange artwork behaviour and unexpected SpotifyImageData


I use Scripting Bridge (Cocoa) to access AppleScript methods and properties of Spotify. For example, I need to access artwork of the current playing track.

On the most of my machines Spotify pushes an ordinary instance of NSImage class, which I can access via something like [[spotifyApp currentTrack] artwork], and everything works as expected.

But on the one of my machines and one friend's machine—instead of an instance of NSImage class—I get very strange SpotifyImageData by calling still the same [[spotifyApp currentTrack] artwork]. This class has no methods (I tried to search for those methods via Objective-C runtime mechanisms) and no properties. I cannot use it as NSImage, because it is not an image, in fact. What is it? How should I handle it? This strange bug appeared only in the latest releases of Spotify and had not been spotted in previous releases.

All my machines have got the same version of OS X and the same latest version of Spotify installed. Also, no third-party system-wide utilities are being used on my Macs.


Solution

  • As per the scripting definitions file, it's an "image data: Image data in TIFF format". I've never really used Cocoa Scripting, but try casting it as an NSData.