Spaces:
Configuration error
Configuration error
Update app.py
Browse files135 unmodified lines136137138139140140141142143143144144145146147148149150151150152153154153155156157158159160161162163164165166167168169170171172173135 unmodified lines
stream_url = url_or_path
if "youtube.com" in url_or_path or "youtu.be" in url_or_path:
# הגדרות עקיפת חסימות בשרת (User-Agent + מעקף פורמט)
ydl_opts = {
'format': 'best',
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best',
'quiet': True,
'no_warnings': True,
'live_from_start': False,
'source_address': '0.0.0.0'
'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'nocheckcertificate': True,
}
try:
print(f"🔍 מנסה לחלץ וידאו מ-YouTube: {url_or_path}")
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(url_or_path, download=False)
stream_url = info.get('url') or info.get('manifest_url')
print(f"✅ Extracted Stream URL: {stream_url[:60] if stream_url else 'None'}...")
print(f"✅ קישור וידאו חולץ בהצלחה!")
except Exception as e:
print(f"❌ שגיאה בחילוץ הקישור מ-YouTube: {e}")
return False, f"שגיאה בחילוץ הוידאו: {e}"
return False, f"יוטיוב חסם את השרת: {e}"
# ניסיון פתיחת הוידאו דרך OpenCV
self.cap = cv2.VideoCapture(stream_url)
if not self.cap.isOpened():
print("❌ OpenCV נכשל בפתיחת הזרם.")
return False, "לא ניתן לפתוח את הוידאו ב-OpenCV"
self.is_running = True
self.is_paused = False
Thread(target=self._capture_loop, daemon=True).start()
Thread(target=self._yolo_loop, daemon=True).start()
Thread(target=self._socket_emit_loop, daemon=True).start()
print("🚀 הזרמת הוידאו החלה בהצלחה!")
return True, "הזרמה הופעלה בהצלחה"
def _capture_loop(self):app.py+11-5