def get_cnmt_data(path=None,TD=None,filter=None,target=None,file=None): if path==None and file==None: return False if file != None: remote=file type='file' remote.rewind() elif path.startswith('http'): url=path remote=Public.location(url);readable=remote.readable if not readable: return False type='file' else: if path=='pick': account=Private.token_picker() TD=Private.TD_picker(account) return test=path.split(".+") if TD=='pick': TD=Private.TD_picker(path) if len(test)>1 or path.endswith('/') or path.endswith('\\'): type="folder" else: ID,name,type,size,md5,remote=Private.get_Data(path,TD=TD,Print=False) if type!='file': # print('Path is a folder') Private.folderpicker(path,TD=TD,filter=filter,mode='get_cnmt_data') return else: files_list=get_files_from_head(remote,remote.name) # print(files_list) for i in range(len(files_list)): if (files_list[i][0]).endswith('.cnmt.nca'): nca_name=files_list[i][0] off1=files_list[i][1] off2=files_list[i][2] sz=files_list[i][3] if target==None: break # print(nca_name) # print(target) if str(nca_name).lower()==str(target).lower(): break remote.seek(off1,off2) buf=int(sz) try: nca=Nca() nca.open(MemoryFile(remote.read(buf))) nca.rewind() cnmt=io.BytesIO(nca.return_cnmt()) titleid,titleversion,base_ID,keygeneration,rightsId,RSV,RGV,ctype,metasdkversion,exesdkversion,hasHtmlManual,Installedsize,DeltaSize,ncadata=cnmt_data(cnmt,nca,nca_name) d={} d['titleid']=titleid;d['version']=titleversion;d['baseid']=base_ID;d['keygeneration']=keygeneration;d['rightsId']=rightsId; d['rsv']=RSV;d['rgv']=RGV;d['ctype']=ctype;d['metasdkversion']=metasdkversion;d['exesdkversion']=exesdkversion; d['hasHtmlManual']=hasHtmlManual;d['Installedsize']=Installedsize;d['DeltaSize']=DeltaSize;d['ncadata']=ncadata; # print(d) return d,files_list,remote except IOError as e: print(e, file=sys.stderr)
def supertrimm(path,ofolder,TD=None,filter=None,file=None): buf=64*1024;buffer=buf if path.startswith('http'): url=path if file==None: remote=Public.location(url);readable=remote.readable else: remote=file;readable=remote.readable if not readable: return False type='file' else: if path=='pick': account=Private.token_picker() TD=Private.TD_picker(account) return test=path.split(".+") if TD=='pick': TD=Private.TD_picker(path) if len(test)>1 or path.endswith('/') or path.endswith('\\'): type="folder" else: ID,name,type,size,md5,remote=Private.get_Data(path,TD=TD,Print=False) if type!='file': # print('Path is a folder') Private.folderpicker(path,TD=TD,filter=filter,mode='supertrimm') return else: if remote.name.endswith(".xci"): supertrimm_xci(remote,ofolder) elif remote.name.endswith(".xcz"): from Drive.Decompress import decompress decompress(path,ofolder,TD)