Spaces:
Configuration error
Configuration error
Update app.py
Browse files136 unmodified lines1371381391401411421431441451461471481491501517 unmodified lines1591601611621631641651661671681692 unmodified lines172173174175176177136 unmodified linesstream_url = url_or_pathif "youtube.com" in url_or_path or "youtu.be" in url_or_path:ydl_opts = {'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best/b','quiet': True,'no_warnings': True,'extractor_args': {'youtube': {'player_client': ['android', 'ios', 'tv_embedded', 'web']}}}if os.path.exists(COOKIES_PATH):ydl_opts['cookiefile'] = COOKIES_PATH7 unmodified linesprint("โ ืงืืฉืืจ ืืืืื ืืืืฅ ืืืฆืืื!")except Exception as e:print(f"โ ืฉืืืื ืืืืืืฅ YouTube: {e}")return False, f"ืืืืืื ืืืจืฉ ืืืืืช (Bot Protection). ืืืืืฅ ืืืขืืืช cookies.txt ืื ืืืฉืชืืฉ ืืงืืฉืืจ MP4 ืืฉืืจ."self.cap = cv2.VideoCapture(stream_url)if not self.cap.isOpened():return False, "ืื ื ืืชื ืืคืชืื ืืช ืืืืืื ืืจื OpenCV"self.is_running = Trueself.is_paused = False2 unmodified linesThread(target=self._yolo_loop, daemon=True).start()Thread(target=self._socket_emit_loop, daemon=True).start()return True, "ืืืจืื ืืืคืขืื ืืืฆืืื"def _capture_loop(self):136 unmodified lines1371381391401411421431441451461471487 unmodified lines1561571581591601611621631641651661672 unmodified lines170171172173174175176136 unmodified linesstream_url = url_or_pathif "youtube.com" in url_or_path or "youtu.be" in url_or_path:# ืืืืจื ืจืืื ืืืฆืืืช ืคืืจืืืื ืชืงืื ืื ืืืืืืืydl_opts = {'format': 'best/b','quiet': True,'no_warnings': True,'noplaylist': True,}if os.path.exists(COOKIES_PATH):ydl_opts['cookiefile'] = COOKIES_PATH7 unmodified linesprint("โ ืงืืฉืืจ ืืืืื ืืืืฅ ืืืฆืืื!")except Exception as e:print(f"โ ืฉืืืื ืืืืืืฅ YouTube: {e}")return False, f"ืฉืืืื ืืืืืืฅ YouTube: {e}"self.cap = cv2.VideoCapture(stream_url)if not self.cap.isOpened():print("โ OpenCV ื ืืฉื ืืคืชืืืช ืืืจื.")return False, "ืื ื ืืชื ืืคืชืื ืืช ืืืืืื"self.is_running = Trueself.is_paused = False2 unmodified linesThread(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+7-8