#!/usr/bin/env python f = open("vvvvvvmusic.vvv", 'rb') q = f.read() FILE_NAMES = ['00-level-complete.ogg','01-pushing-onwards.ogg','02-positive-force.ogg','03-potential-for-anything.ogg','04-passion-for-exploring.ogg','05-intermission.ogg','06-presenting-vvvvvv.ogg','07-game-complete.ogg','08-predestined-fate.ogg','09-positive-force-reversed.ogg','10-popular-potpourri.ogg','11-pipedream.ogg','12-pressure-cooker.ogg','13-paced-energy.ogg','14-piercing-the-sky.ogg'] startAt = endAt = -1 musStartAt = musEndAt = -1 currentMus = 0 while True: oldStartAt = startAt startAt = q.find("OggS", oldStartAt + 1) endAt = q.find("OggS", startAt + 1) - 1 if oldStartAt >= startAt: break if endAt == -2: endAt = len(q) - 1 sB = ord(q[startAt+5]) if sB == 2: musStartAt = startAt elif sB == 4: musEndAt = endAt print "Found entire Ogg between",musStartAt,musEndAt print "Filename: ",FILE_NAMES[currentMus] f2 = open(FILE_NAMES[currentMus], 'wb') f2.write(q[musStartAt:musEndAt]) f2.close() currentMus += 1 #print "Found OggS at",startAt,"-",endAt