def extract_music(args, conf): dat_manager = DatManager(conf.get('game', 'path')) exd_manager = ExdManager(dat_manager) output_path = path.join(conf.get('output', 'path'), 'music') tried = 0 completed = 0 for data in exd_manager.get_category('BGM').get_ln_data(0).values(): print('----------') tried = tried + 1 file_path = data[0].decode('utf-8') if file_path == '': continue output_file_path = path.join(output_path, file_path) if not path.exists(path.dirname(output_file_path)): makedirs(path.dirname(output_file_path)) try: print('Song:', file_path) file_data = dat_manager.get_file(file_path) except: continue if hasattr(file_data, 'getvalue'): completed = completed + 1 with open(output_file_path, 'wb') as file_handle: file_handle.write(file_data.getvalue()) else: continue print('tried', tried, 'completed', completed)
def extract_file(args, conf): dat_manager = DatManager(conf.get('game', 'path')) output_file_path = path.join(conf.get('output', 'path'), 'file', args.name) file_data = dat_manager.get_file(args.name) if not path.exists(path.dirname(output_file_path)): makedirs(path.dirname(output_file_path)) if output_file_path.endswith('.tex'): with open(output_file_path[:-3] + 'dds', 'wb') as file_handle: file_handle.write(Texture(file_data).get_as_dds().getvalue()) else: with open(output_file_path, 'wb') as file_handle: file_handle.write(file_data.getvalue())