# main.py
# 프로그램 실행 진입점, UI 및 사용자 상호작용 관리
import configparser
from video_editor import generate_final_video
from utils import get_current_date_str

def main_console():
    """콘솔 기반으로 사용자 입력을 받아 영상을 처리하는 함수"""
    config = configparser.ConfigParser()
    config.read('config.ini', encoding='utf-8')

    print("--- 예배 영상 자동 편집 프로그램 ---")
    
    # 사용자 입력
    source_video_path = input("1. 원본 예배 영상 파일 경로를 입력하세요: ")
    sermon_start = input("2. 설교 시작 시간을 (분:초) 형식으로 입력하세요 (예: 30:15): ")
    sermon_end = input("3. 설교 종료 시간을 (분:초) 형식으로 입력하세요 (예: 55:40): ")
    title = input("4. 설교 제목을 입력하세요: ")
    scripture = input("5. 본문 말씀을 입력하세요: ")
    speaker = input("6. 설교자 이름을 입력하세요: ")

    # 파일명 생성
    output_filename = f"{get_current_date_str()}_주일예배_{speaker}목사.mp4"

    print("\n영상 처리를 시작합니다...")

    try:
        generate_final_video(
            config=config,
            source_video_path=source_video_path,
            sermon_start_time=sermon_start,
            sermon_end_time=sermon_end,
            title=title,
            scripture=scripture,
            speaker=speaker,
            output_filename=output_filename
        )
        print(f"\n🎉 영상 처리가 완료되었습니다!")
        print(f"결과물은 '{config['Paths']['output_folder']}' 폴더에 '{output_filename}' 이름으로 저장되었습니다.")
    except Exception as e:
        print(f"\n❌ 오류가 발생했습니다: {e}")
        # 여기에 error_handler.py의 로깅 함수를 호출할 수 있습니다.

if __name__ == "__main__":
    main_console()
