Skip to content

Instantly share code, notes, and snippets.

@Pldare
Last active August 20, 2021 05:26
Show Gist options
  • Save Pldare/1d8ef2f4dd3d486e453c96b978cc526f to your computer and use it in GitHub Desktop.
Save Pldare/1d8ef2f4dd3d486e453c96b978cc526f to your computer and use it in GitHub Desktop.
sizeinfo parse
import struct
def tobit(x):
if x>=1000000000000:
return str(round(x/1000000000000,2))+'TB'
elif x>=1000000000:
return str(round(x/1000000000,2))+'GB'
elif x>=1000000:
return str(round(x/1000000,2))+'MB'
elif x>=1000:
return str(round(x/1000,2))+'KB'
else:
return str(round(x,2))
a=open("SizeInfo.bytes","rb")
a.seek(0x119)
count=struct.unpack("I",a.read(4))[0]
print(count)
a.seek(0x1b7)
all_size=0
list=open("url_list.txt","w")
for i in range(0,count-1):
unk7=struct.unpack("L",a.read(4))[0]#magic logo?
unk5=struct.unpack("I",a.read(4))[0]#unk index2?
str_size=struct.unpack(">H",a.read(2))[0]
str_name=str(a.read(str_size),encoding = "utf8")
file_size=struct.unpack("I",a.read(4))[0]#file_size
unk3=struct.unpack("I",a.read(4))[0]#zero
unk4=struct.unpack("I",a.read(4))[0]#?
hash_size=struct.unpack(">H",a.read(2))[0]
hash_name=str(a.read(hash_size),encoding = "utf8")
unk8=struct.unpack("B",a.read(1))[0]#one
unk6=struct.unpack("I",a.read(4))[0]#unk index?
print(str_name,hash_name)
print(unk7,unk5,file_size,unk3,unk4,unk8,unk6)
all_size+=file_size
list.write('https://file.unitia.johren.games/tw/WebGL/'+str_name+"\n")
list.close
print(tobit(all_size))
def tobit(x)
if x>=1000000000000
return ((x/1000000000000).round(2)).to_s+'TB'
end
if x>=1000000000
return ((x/1000000000).round(2)).to_s+'GB'
elsif x>=1000000
return ((x/1000000).round(2)).to_s+'MB'
elsif x>=1000
return ((x/1000).round(2)).to_s+'KB'
else
return ((x).round(2)).to_s
end
end
a=File.open("SizeInfo.bytes","rb")
a.seek(0x119)
count=a.read(4).unpack("V")[0]
a.seek(0x1b7)
all_size=0
list=File.open("url_list.txt","wb")
for i in 0...count
unk7=a.read(4).unpack("N")[0]#magic logo?
unk5=a.read(4).unpack("V")[0]#unk index2?
str_size=a.read(2).unpack("n")[0]
str_name=a.read(str_size).to_s
puts str_name
file_size=a.read(4).unpack("V")[0]#file_size
unk3=a.read(4).unpack("V")[0]#zero
unk4=a.read(4).unpack("N")[0]#?
hash_size=a.read(2).unpack("n")[0]
hash_name=a.read(hash_size).to_s
unk8=a.read(1).unpack("C")[0]#one
unk6=a.read(4).unpack("V")[0]#unk index?
next if str_name == ""
print [str_name,hash_name],"\n"
print [unk7,unk5,file_size,unk3,unk4,unk8,unk6],"\n"
all_size+=file_size
list<<'https://file.unitia.johren.games/tw/WebGL/'+str_name+"\n"
end
list.close
puts tobit(all_size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment