Appscript to write iTunes artwork

Posted by Kartik Aiyer on Stack Overflow See other posts from Stack Overflow or by Kartik Aiyer
Published on 2009-10-28T22:31:14Z Indexed on 2010/05/07 9:28 UTC
Read the original article Hit count: 398

Filed under:
|

I'm trying to capture artwork from a pict file and embed into a track on iTunes using python appscript. I did something like this:

imFile = open('/Users/kartikaiyer/temp.pict','r')
data = imFile.read()
it = app('iTunes')
sel = it.current_track.get()
sel.artworks[0].data_.set(data[513:])

I get an error OSERROR: -1731 MESSAGE: Unknown object

Similar applescript code looks like this:

tell application "iTunes"
    set the_artwork to read (POSIX file "/Users/kartikaiyer/temp.pict") from 513 as picture
    set data of artwork 1 of current track to the_artwork
end tell

I tried using ASTranslate but it never instantiates 'the_artwork' and then throws an error when there is a reference to the_artwork. Can anyone help. I'm new to appscript and python in general.

© Stack Overflow or respective owner

Related posts about python

Related posts about appscript