-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_simple_videos.py
More file actions
139 lines (112 loc) · 4.58 KB
/
create_simple_videos.py
File metadata and controls
139 lines (112 loc) · 4.58 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env python3
"""
Quick News Video Creator - Simplified Version
Creates news videos without ImageMagick dependency
"""
import os
import sys
import asyncio
import logging
from datetime import datetime
# Add src to path
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
from config_manager import ConfigManager
from news_fetcher import NewsFetcher
from text_summarizer import TextSummarizer
from simple_video_creator import SimpleVideoCreator
from image_manager import ImageManager
from audio_manager import AudioManager
# Setup logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
async def create_simple_news_videos():
"""Create simple news videos without complex effects"""
print("🚀 Simple News Video Creator")
print("=" * 50)
print("Creating videos without text animations (ImageMagick-free)")
print()
try:
# Initialize components
config_manager = ConfigManager()
config = config_manager.get_config()
news_fetcher = NewsFetcher(config)
text_summarizer = TextSummarizer(config)
image_manager = ImageManager(config)
audio_manager = AudioManager(config)
video_creator = SimpleVideoCreator(config)
print("📰 Fetching latest news...")
# Fetch news (RSS only for this demo)
articles = await news_fetcher.fetch_latest_news()
if not articles:
print("❌ No articles found")
return False
print(f"✅ Found {len(articles)} articles")
# Process up to 2 articles for demo
max_videos = 2
created_videos = 0
for i, article in enumerate(articles[:max_videos]):
print(f"\n🎬 Creating video {i+1}/{min(len(articles), max_videos)}")
print(f"📰 Title: {article.get('title', 'Unknown')[:60]}...")
try:
# Summarize article
summary = await text_summarizer.summarize(article.get('content', ''))
if summary:
article['summary'] = summary
article['summary_data'] = {'text': summary}
# Get images
print("🖼️ Fetching images...")
images = await image_manager.get_images_for_article(article)
# Create audio (optional)
audio_path = None
try:
print("🎵 Creating audio narration...")
audio_path = await audio_manager.create_narration(article)
except Exception as e:
print(f"⚠️ Audio creation failed: {e}")
# Create video
print("🎬 Creating video...")
video_path = await video_creator.create_video(
article=article,
images=images,
audio_path=audio_path
)
if video_path and os.path.exists(video_path):
file_size = os.path.getsize(video_path) / (1024 * 1024) # MB
print(f"✅ Video created: {os.path.basename(video_path)}")
print(f"📊 Size: {file_size:.1f} MB")
created_videos += 1
else:
print("❌ Video creation failed")
except Exception as e:
print(f"❌ Error processing article: {e}")
continue
print(f"\n🎉 Created {created_videos} videos!")
print(f"📁 Check the 'videos' folder for your content")
return created_videos > 0
except Exception as e:
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()
return False
def main():
"""Main function"""
print("Simple News Video Creator")
print("Creates videos using basic MoviePy functionality")
print("(No ImageMagick required)")
print()
# Ensure directories exist
os.makedirs('videos', exist_ok=True)
os.makedirs('logs', exist_ok=True)
os.makedirs('assets/temp', exist_ok=True)
# Run the video creation
success = asyncio.run(create_simple_news_videos())
if success:
print("\n✅ Process completed successfully!")
print("Your news videos are ready in the 'videos' folder")
else:
print("\n❌ Process failed")
print("Check the error messages above for details")
if __name__ == "__main__":
main()