Reputation: 2771
In a Cocoa application, I'm looking for a solution to retrieve album artwork from iTunes without requiring iTunes itself to be launched and running in the background.
The usual and perhaps only solution, Scripting Bridge, and inherently AppleScript, will launch iTunes prior to executing any commands.
Album artwork is the only information which cannot be obtained from parsing iTunes Library.xml
. iTunes obfuscates the storage of artwork in the following manner, for a given track: ~/{Library Path}/Album Artwork/Cache/D989408F65D05F99/04/13/04/D989408F65D05F99-EB5B7A9086F4B4D4.itc
.
Anyone know of a technique to obtain album art without launching iTunes? I could always go a different route, such as using Amazon's data service, but I'd prefer a local iTunes-based solution.
Upvotes: 5
Views: 2564
Reputation: 1
The ITLibrary Framework has a function (link):
(ITLibArtwork *)artworkForMediaFile:(NSURL *)mediaFileURL;
You will need the location of the track that your wanting to get the artwork for.
If you have the PersistentID
, then you’ll have to query the Library to get the
ITMediaItem
, then access its location property.
Or, if you already have the ITMediaItem
, now you can get its artwork 1st by checking the artworkAvailable
property.
If yes then get its artwork property, which is of ITLibArtwork
Class. See here for more info on that class.
Upvotes: 0
Reputation: 976
iTunes 11+ (macOS 10.13+) introduced iTunes Library Framework that has this capability too you do not need to parse the iTunes Library.xml anymore or read the storage folders of the tracks
Upvotes: 2
Reputation: 16986
The filenames are an amalgam of the library ID (D989408F65D05F99) and the track's ID (EB5B7A9086F4B4D4). The directory structure comes from the library ID and the last three digits of the track's ID converted to decimal, ie 4D4 becomes 04, 13, 04.
The .itc files seem to have a RIFF/chunked type structure. There is a bit on the structure of the files here.
Upvotes: 6