views:

92

answers:

1

I'm using Python appscript to write artwork to my iTunes Songs. I have a file stored in .pict format and when i use the normal open and read() routines, it reads the content as a string (encoded in utf-8).

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

Is the code I'm using. it fails with a objct not recognized and I'm guessing its because the set parameter is a utf-8 encoded strign, Any ideas as to how I can coerce 'data' to a bytestream and use that as a set parameter. BinAscii module doesn't have the functions I need. Any help would be much appreciated.

Thanks Kartik

+7  A: 

Try setting the read mode to binary:

imFile = open('/Users/kartikaiyer/temp.pict','rb')
DeckerDK
I did tht too, but read() always reads it in as string...
Kartik Aiyer