File size: 734 Bytes
7e99d31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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