Dayem121's picture
Create file_utils.py
7e99d31 verified
Raw
History Blame Contribute Delete
734 Bytes
import zipfile
import os
def package_files(content, images, audio):
os.makedirs("output", exist_ok=True)
txt_path = "output/generated_content.txt"
with open(txt_path, "w", encoding="utf-8") as f:
f.write(f"Title: {content['title']}\n\n")
f.write("Outline:\n")
f.write(content["outline"] + "\n\n")
f.write("Full Content:\n")
f.write(content["full_content"])
zip_path = "output/content_package.zip"
with zipfile.ZipFile(zip_path, "w") as zipf:
zipf.write(txt_path, "generated_content.txt")
for img in images:
zipf.write(img, os.path.basename(img))
if audio:
zipf.write(audio, os.path.basename(audio))
return zip_path