File size: 2,236 Bytes
d49de5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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