#!/bin/bash
cd /root/videos

# Generate score overlay graphics using Python
python3 -c "
from PIL import Image, ImageDraw, ImageFont
import os
os.chdir('/root/videos')

try:
    font_big = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 60)
    font_small = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 36)
    font_score = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 80)
except:
    font_big = ImageFont.load_default()
    font_small = ImageFont.load_default()
    font_score = ImageFont.load_default()

# Create score overlay image (transparent PNG)
overlay = Image.new('RGBA', (1280, 720), (0,0,0,0))
draw = ImageDraw.Draw(overlay)

# Top bar - dark semi-transparent
draw.rectangle([0, 0, 1280, 100], fill=(0,0,0,180))

# USA flag colors bar
draw.rectangle([0, 0, 1280, 8], fill=(0, 50, 160))

# Score display
draw.text((640, 50), 'USA  4 - 1  PARAGUAY', fill=(255,255,255), font=font_score)

# Bottom bar - for captions
draw.rectangle([0, 650, 1280, 720], fill=(0,0,0,180))

overlay.save('score_overlay.png')
print('Overlay created')

# Create intro title card
intro = Image.new('RGB', (1280, 720), (10, 30, 80))
draw2 = ImageDraw.Draw(intro)
draw2.text((640, 200), '2026 世界杯快讯', fill=(255,200,50), font=font_big)
draw2.text((640, 300), '美国 4-1 巴拉圭', fill=(255,255,255), font=font_score)
draw2.text((640, 400), '洛杉矶 · 小组赛首战', fill=(200,200,255), font=font_small)
draw2.text((640, 500), '东道主主场大胜，开门红！', fill=(255,200,50), font=font_small)
intro.save('usa_intro.png')
print('Intro created')
"

echo "Graphics ready"
