Now catches all files, splits the file names by their number, and append the file types number to the end of the file extension
This commit is contained in:
33
main.py
33
main.py
@@ -44,13 +44,13 @@ class BZZCompressor:
|
|||||||
tmp = (i) * 12
|
tmp = (i) * 12
|
||||||
files.append(
|
files.append(
|
||||||
{
|
{
|
||||||
"pt_a": hex(
|
"type": hex(
|
||||||
int.from_bytes(data[12 + tmp : 12 + tmp + 4], "little")
|
int.from_bytes(data[12 + tmp : 12 + tmp + 4], "little")
|
||||||
),
|
),
|
||||||
"pt_b": hex(
|
"file_end": hex(
|
||||||
int.from_bytes(data[12 + tmp + 4 : 12 + tmp + 8], "little")
|
int.from_bytes(data[12 + tmp + 4 : 12 + tmp + 8], "little")
|
||||||
),
|
),
|
||||||
"pt_c": hex(
|
"padding_end": hex(
|
||||||
int.from_bytes(data[12 + tmp + 8 : 12 + tmp + 12], "little")
|
int.from_bytes(data[12 + tmp + 8 : 12 + tmp + 12], "little")
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,19 @@ class BZZCompressor:
|
|||||||
# individual files from the .bzz
|
# individual files from the .bzz
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
index = 0x800
|
starting_index = 0x800
|
||||||
|
|
||||||
|
# File Loop
|
||||||
|
for file_num, file in enumerate(files):
|
||||||
|
print(hex(starting_index))
|
||||||
|
|
||||||
|
index = starting_index
|
||||||
|
|
||||||
|
# Prepping for the next loop
|
||||||
|
file_end = starting_index + int(file.get("file_end")[2:], 16)
|
||||||
|
starting_index = starting_index + int(file.get("padding_end")[2:], 16)
|
||||||
|
|
||||||
|
print(hex(file_end))
|
||||||
|
|
||||||
# Getting our method, this is likely imprecise, since I'm one dealing with one
|
# Getting our method, this is likely imprecise, since I'm one dealing with one
|
||||||
# method type, but it gets what I want
|
# method type, but it gets what I want
|
||||||
@@ -206,11 +218,18 @@ class BZZCompressor:
|
|||||||
out_data = output_buffer
|
out_data = output_buffer
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(f"{output_folder}/{input_file}.file", "wb") as outfile:
|
with open(
|
||||||
|
f"{output_folder}/{input_file}_{str(file_num).zfill(3)}.file{file['type'][2:]}",
|
||||||
|
"wb",
|
||||||
|
) as outfile:
|
||||||
outfile.write(out_data)
|
outfile.write(out_data)
|
||||||
print(f"File {output_folder}/{input_file}.file saved successfully!")
|
print(
|
||||||
|
f"File {output_folder}/{input_file}_{str(file_num).zfill(3)}.file{file['type'][2:]} saved successfully!"
|
||||||
|
)
|
||||||
|
|
||||||
with open(f"{output_folder}/{input_file}.overflow.file", "wb") as outfile:
|
with open(
|
||||||
|
f"{output_folder}/{input_file}.overflow.file", "wb"
|
||||||
|
) as outfile:
|
||||||
outfile.write(overflow_buffer)
|
outfile.write(overflow_buffer)
|
||||||
print(
|
print(
|
||||||
f"File {output_folder}/{input_file}.overflow.file saved successfully!"
|
f"File {output_folder}/{input_file}.overflow.file saved successfully!"
|
||||||
|
Reference in New Issue
Block a user