Skip to content

Commit

Permalink
add support for SNK 40th collection bundle format
Browse files Browse the repository at this point in the history
also fixed some python3 stuff
  • Loading branch information
ghoost82 committed Feb 24, 2020
1 parent 425b2c1 commit 9353289
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
18 changes: 13 additions & 5 deletions bplist.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import struct
from datetime import datetime, timedelta
import plistlib

class BPListReader(object):
def __init__(self, s):
Expand Down Expand Up @@ -198,13 +199,20 @@ def __resolveObject(self, idx):

def parse(self):
# read header
if self.data[:8] != b'bplist00':
if self.data[:5] == b'<?xml':
# load XML formated data and convert it
pl = {'bundles': {}}
for bundle in plistlib.loads(self.data)['bundles']:
pl['bundles'].update({bundle['bundleName']: {'files': bundle['files']}})
return pl
elif self.data[:8] != b'bplist00':
raise Exception('Bad magic')

# read trailer
self.offset_size, self.object_ref_size, self.number_of_objects, self.top_object, self.table_offset = struct.unpack('!BB4xI4xI4xI', self.data[-26:])
self.top_object = self.table_offset - 8
#print ("** plist offset_size:",self.offset_size,"objref_size:",self.object_ref_size,"num_objs:",self.number_of_objects,"top:",self.top_object,"table_ofs:",self.table_offset)
#print("** plist offset_size: %d objref_size: %d num_objs: %d top: %d table_ofs: %d" %
# (self.offset_size, self.object_ref_size, self.number_of_objects, self.top_object, self.table_offset))

# read offset table
self.offset_table = self.data[self.table_offset:-26]
Expand All @@ -214,14 +222,14 @@ def parse(self):
offset_entry = ot[:self.offset_size]
ot = ot[self.offset_size:]
self.offsets.append(self.__unpackIntStruct(self.offset_size, offset_entry))
#print "** plist offsets:",self.offsets
#print("** plist offsets: %s" % (self.offsets))

# read object table
self.objects = []
k = 0
for i in self.offsets:
obj = self.__unpackItem(i)
#print "** plist unpacked",k,type(obj),obj,"at",i
#print("** plist unpacked %d %s %s at %d" % (k, type(obj), obj, i))
k += 1
self.objects.append(obj)

Expand Down
2 changes: 2 additions & 0 deletions extract.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

from bplist import BPListReader

import os
Expand Down
6 changes: 4 additions & 2 deletions tidy.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

import os
import sys

Expand All @@ -21,15 +23,15 @@
# Move Second Impact music from Third Strike dir to Second Impact dir.
for filename in third_strike_files:
if filename.startswith("SF3SI") and filename.endswith(".ogg"):
print filename
print(filename)
old = os.path.join(third_strike_path, filename)
new = os.path.join(second_impact_path, filename)
os.rename(old, new)

# Move Third Strike music from Main dir to Third Strike dir.
for filename in main_files:
if filename.startswith("SF3TS") and filename.endswith(".ogg"):
print filename
print(filename)
old = os.path.join(main_path, filename)
new = os.path.join(third_strike_path, filename)
os.rename(old, new)

0 comments on commit 9353289

Please sign in to comment.