def rebuild_nsp(ifolder, ofolder, buffer=65536, delta=False, xml_gen=False, export='nsp'): extlist = ['nsp', 'nsz'] files = listmanager.folder_to_list(ifolder, extlist) from Fs import Nsp import decompressor total = len(files) for filepath in files: if filepath.endswith('nsp'): basename = os.path.basename(os.path.abspath(filepath)) endfile = os.path.join(ofolder, basename) print('Processing: ' + filepath) f = Nsp(filepath) f.rebuild(buffer, endfile, delta, False, xml_gen) f.flush() f.close() elif filepath.endswith('nsz'): basename = os.path.basename(os.path.abspath(filepath)) endname = basename[:-1] + 'p' endname = os.path.join(ofolder, endname) decompressor.decompress_nsz(filepath, endname, buffer, delta, xml_gen) total -= 1 print("**********************************************************") print(('Still {} files to process').format(str(total))) print("**********************************************************")
def get_key_fromdict(fp): if fp.endswith('.nsp') or fp.endswith('.nsx'): files_list=sq_tools.ret_nsp_offsets(fp) files=list();filesizes=list() fplist=list() for k in range(len(files_list)): entry=files_list[k] fplist.append(entry[0]) for i in range(len(files_list)): entry=files_list[i] filepath=entry[0] if filepath.endswith('.cnmt.nca'): f=Nsp(fp,'rb') titleid,titleversion,base_ID,keygeneration,rightsId,RSV,RGV,ctype,metasdkversion,exesdkversion,hasHtmlManual,Installedsize,DeltaSize,ncadata=f.get_data_from_cnmt(filepath) titlekey,dectkey=f.db_get_titlekey(rightsId,keygeneration) f.flush() f.close() # print(titlekey);print(rightsId) return titlekey
def decompress_nsz(input,output,buffer = 65536,delta=False,xml_gen=False): f = Nsp(input, 'r+b') f.decompress_direct(output,buffer,delta,xml_gen) f.flush() f.close()
def nsz_hasher(input,buffer = 65536): f = Nsp(input, 'r+b') f.nsz_hasher(buffer) f.flush() f.close()
def verify_nsz(input,buffer = 65536): f = Nsp(input, 'r+b') f.verify_nsz(buffer) f.flush() f.close()
def decompress_nsz(input, output, buffer=65536): f = Nsp(input, 'r+b') f.decompress_direct(output, buffer) f.flush() f.close()