"""
YouTube Learning - Eden learns from videos
"""
import subprocess
from pathlib import Path
from datetime import datetime
import json

class EdenVideoLearner:
    def __init__(self):
        self.learning_dir = Path("/Eden/LEARNING/videos")
        self.learning_dir.mkdir(parents=True, exist_ok=True)
        print("📺 YouTube Learning initialized")
    
    def learn_from_video(self, video_url, title="video"):
        """Download and transcribe a video"""
        print(f"📺 Learning: {video_url}")
        
        # Simplified - just download
        safe_title = "".join(c for c in title if c.isalnum() or c in ' _').strip()
        output = self.learning_dir / f"{safe_title}.mp4"
        
        try:
            cmd = ['yt-dlp', '-o', str(output), video_url]
            subprocess.run(cmd, check=True, capture_output=True)
            
            return {
                'success': True,
                'title': title,
                'file': str(output)
            }
        except Exception as e:
            return {'success': False, 'error': str(e)}

eden_video_learner = EdenVideoLearner()
