#!/usr/bin/env python2.1 import struct contents = open('iTunesDB','r').read() file_pos = 0 file_len = len(contents) code_names = {1:'Title', 2:'Filename', 3:'Album', 4:'Artist', 5:'Genre', 6:'Filetype', 7:'Unknown', 8:'Comment', 100:'Unknown'} item_id = 0 item = {} items = {} prop_count = 0 while file_pos < file_len: # move through the file first_16_bytes = contents[file_pos:file_pos+16] second_16_bytes = contents[file_pos+16:file_pos+32] pad, code, jump, \ myLen, count = struct.unpack("<2s2sLLL", first_16_bytes) if prop_count == 0 and item: items[item_id] = item item = {} item_id = 0 if code == "bd": # start code print "%.8x Beginning of database" % file_pos elif code == "it": # a song list item item_id,x,x,x = struct.unpack("