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:
2025-09-20 19:16:28 -06:00
parent 62b6bf742c
commit 7d8e5d8b56

33
main.py
View File

@@ -44,13 +44,13 @@ class BZZCompressor:
tmp = (i) * 12
files.append(
{
"pt_a": hex(
"type": hex(
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")
),
"pt_c": hex(
"padding_end": hex(
int.from_bytes(data[12 + tmp + 8 : 12 + tmp + 12], "little")
),
}
@@ -68,7 +68,19 @@ class BZZCompressor:
# 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
# method type, but it gets what I want
@@ -206,11 +218,18 @@ class BZZCompressor:
out_data = output_buffer
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)
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)
print(
f"File {output_folder}/{input_file}.overflow.file saved successfully!"