File size: 1,885 Bytes
83ee596
600897e
 
 
 
83ee596
 
 
 
 
 
600897e
83ee596
600897e
 
 
83ee596
 
600897e
 
 
83ee596
 
 
600897e
 
 
 
 
 
83ee596
 
 
 
 
 
 
 
 
 
 
 
600897e
 
 
83ee596
600897e
 
83ee596
 
600897e
 
 
83ee596
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import uuid
import zipfile
import shutil

from beat_generator.riffusion_cpu import generate_audio_loop
from content_generator.hooks import generate_hooks
from content_generator.captions import generate_captions
from content_generator.ideas import generate_content_ideas
from content_generator.scripts import generate_short_scripts


def build_creator_pack(niche, style, bpm, tone, goal):
    # Create temp folder
    pack_id = uuid.uuid4().hex
    folder = f"assets/temp/{pack_id}"
    os.makedirs(folder, exist_ok=True)

    # -----------------------------------
    # 1. Generate beats & copy correctly
    # -----------------------------------
    for i in range(3):
        beat_path = generate_audio_loop(style, bpm)

        # Copy safely using Python, NOT shell commands
        shutil.copy(beat_path, f"{folder}/beat_{i+1}.wav")

    # -----------------------------------
    # 2. Generate text files
    # -----------------------------------
    with open(f"{folder}/hooks.txt", "w") as f:
        f.write("\n".join(generate_hooks(niche, tone)))

    with open(f"{folder}/captions.txt", "w") as f:
        f.write("\n".join(generate_captions(niche, tone)))

    with open(f"{folder}/ideas.txt", "w") as f:
        f.write("\n".join(generate_content_ideas(niche, goal)))

    with open(f"{folder}/scripts.txt", "w") as f:
        f.write("\n".join(generate_short_scripts(niche, tone)))

    # -----------------------------------
    # 3. Build ZIP file safely
    # -----------------------------------
    zip_path = f"{folder}.zip"

    with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
        for root, _, files in os.walk(folder):
            for file in files:
                file_path = os.path.join(root, file)
                arc_path = os.path.relpath(file_path, folder)
                zipf.write(file_path, arc_path)

    return zip_path