import os import argparse import logging from dotenv import load_dotenv from found_protocol import FoundProtocolPipeline from found_protocol.utils import setup_logging, save_consciousness_log, generate_statistics def main(): setup_logging() load_dotenv() parser = argparse.ArgumentParser( description="Run the FOUND Protocol consciousness extraction on video files." ) parser.add_argument( "path", type=str, help="Path to a single video file or a directory of videos." ) parser.add_argument( "--no-cache", action="store_true", help="Force re-analysis and ignore any cached results." ) parser.add_argument( "--output", type=str, default=None, help="Output path for consciousness log JSON" ) args = parser.parse_args() API_KEY = os.environ.get("GEMINI_API_KEY") if not API_KEY: logging.error("Please set your GEMINI_API_KEY environment variable.") return try: pipeline = FoundProtocolPipeline(api_key=API_KEY) except Exception as e: logging.error(f"Failed to initialize pipeline: {e}") return videos_to_process = [] if os.path.isdir(args.path): logging.info(f"Processing all videos in directory: {args.path}") videos_to_process = sorted([ os.path.join(args.path, f) for f in os.listdir(args.path) if f.endswith(('.mp4', '.mov')) ]) elif os.path.isfile(args.path): videos_to_process.append(args.path) else: logging.error(f"Path not found: {args.path}") return results = [] for video_path in videos_to_process: logging.info(f"--- Running FOUND Protocol on {os.path.basename(video_path)} ---") result = pipeline.run(video_path=video_path, no_cache=args.no_cache) if "error" in result: logging.error(f"Analysis failed: {result['error']}") else: results.append(result) print("\n" + "="*50) print(f"VIDEO: {result.get('video')}") print(f"MARKET VALUE: {result.get('market_val