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)
def interface_file(path, TD): if TD == "pick": TD = Private.TD_picker(path) folder = path TeamDrive = TD response = False files = list() while True: filter = interface_filter(path) files = Private.search_folder(folder, TD=TeamDrive, pickmode="multi", filter=filter, Print=False) if files == False: print("Query returned no files") input('\nPress any key to continue...') clear_Screen() About() return True else: response = interface_menu(files, TeamDrive) if str(response) == "False": return response elif str(response) == "CHANGE": return True
def Interface(): clear_Screen() About() response = False print('\n********************************************************') print('DOWNLOAD SYSTEM') print('********************************************************') while True: print('Input "1" to select folder and file via file-picker') if os.path.exists(remote_lib_file): print('Input "2" to select from libraries') print('') print('Input "0" to go back to the MAIN PROGRAM') print('') print('--- Or INPUT GDRIVE Route OR PUBLIC_LINK ---') print('') ck = input('Input your answer: ') if ck == "0": break elif ck == "1": while True: folder, TD = Private.folder_walker() if folder == False: return False print(folder) response = interface_file(folder, TD) if response == False: return False elif ck == "2" and os.path.exists(remote_lib_file): while True: paths, TDs = pick_libraries() if paths == False: return False response = interface_file(paths, TDs) if response == False: return False elif ck == "0": break elif ck.startswith('http'): url = ck response = interface_menu(url, None, True) elif ck.endswith('/') or ck.endswith('\\'): response = interface_file(ck, "pick") elif (ck[:-1]).endswith('.xc') or (ck[:-1]).endswith('.ns'): TD = Private.TD_picker(ck) response = interface_menu(ck, TD, True) if response == False: break