File size: 1,864 Bytes
76492ed |
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 57 |
import json
from datetime import datetime
def create_download_data(topic, metadata, thumbnail1, thumbnail2, selected_thumbnail):
"""Create downloadable JSON data"""
# Parse metadata
lines = metadata.split('\n')
title = ""
description = ""
tags = ""
for line in lines:
if line.startswith('TITLE:'):
title = line.replace('TITLE:', '').strip()
elif line.startswith('DESCRIPTION:'):
description = line.replace('DESCRIPTION:', '').strip()
elif line.startswith('TAGS:'):
tags = line.replace('TAGS:', '').strip()
data = {
"topic": topic,
"generated_at": datetime.now().isoformat(),
"metadata": {
"title": title,
"description": description,
"tags": tags.split(', ') if tags else []
},
"selected_thumbnail": selected_thumbnail,
"thumbnails_generated": 2
}
return json.dumps(data, indent=2)
def process_content(topic, style, model_choice, text_overlay, overlay_style):
"""Main function to generate all content"""
if not topic.strip():
return "Please enter a topic!", None, None, ""
print(f"Processing: {topic}")
# Generate metadata
print("Generating metadata...")
from metadata_generator import generate_metadata
metadata = generate_metadata(topic, model_choice)
print("Generating thumbnails...")
from image_generator import generate_thumbnails
thumbnail1, thumbnail2 = generate_thumbnails(topic, style, text_overlay, overlay_style)
print("Complete!")
# Create download data
download_data = create_download_data(topic, metadata, thumbnail1, thumbnail2, "thumbnail1")
return metadata, thumbnail1, thumbnail2, download_data |