Spaces:
Sleeping
Sleeping
CI: deploy Docker/PDM Space
Browse files
services/app_service/pages/signal_watch.py
CHANGED
|
@@ -89,60 +89,77 @@ with st.sidebar:
|
|
| 89 |
# Render device information
|
| 90 |
model_manager.render_device_info()
|
| 91 |
|
| 92 |
-
st.sidebar.markdown("---")
|
| 93 |
-
st.sidebar.header("YouTube Live Streams")
|
| 94 |
|
| 95 |
# Show helpful info about live streams
|
| 96 |
-
with st.sidebar.expander("ℹ️ About Live Streams", expanded=False):
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
st.sidebar.markdown("---")
|
| 114 |
-
st.sidebar.header("YouTube cookies (optional)")
|
| 115 |
-
cookies_file =
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
"**Required if YouTube blocks video access:**\n\n"
|
| 121 |
-
"1. Install browser extension: 'Get cookies.txt' or 'cookies.txt'\n"
|
| 122 |
-
"2. Go to YouTube.com and log in\n"
|
| 123 |
-
"3. Export cookies to cookies.txt file\n"
|
| 124 |
-
"4. Upload the file here\n\n"
|
| 125 |
-
"**Alternative:** Make sure you're logged into YouTube in Chrome/Firefox/Safari/Edge\n\n"
|
| 126 |
-
"⚠️ Keep cookies private; they contain your login session"
|
| 127 |
-
),
|
| 128 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
if cookies_file is not None:
|
| 131 |
try:
|
| 132 |
-
|
| 133 |
-
if
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
else:
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
except Exception as exc:
|
| 144 |
cookies_path = None
|
| 145 |
-
st.error(f"Failed to
|
| 146 |
else:
|
| 147 |
cookies_path = None
|
| 148 |
|
|
@@ -241,14 +258,14 @@ def extract_youtube_stream_url(url: str, cookies_path: str | None = None) -> str
|
|
| 241 |
st.error("yt-dlp found but not working properly.")
|
| 242 |
return None
|
| 243 |
|
| 244 |
-
# Hardcoded cookies as fallback (from your provided cookies.txt)
|
| 245 |
-
hardcoded_cookies = """# Netscape HTTP Cookie File
|
| 246 |
-
# https://curl.haxx.se/rfc/cookie_spec.html
|
| 247 |
-
# This is a generated file! Do not edit.
|
| 248 |
|
| 249 |
-
.youtube.com TRUE / TRUE 1776851748 VISITOR_INFO1_LIVE m4CAb_qRhZM
|
| 250 |
-
.youtube.com TRUE / TRUE 1776851748 VISITOR_PRIVACY_METADATA CgJBVRIEGgAgQw%3D%3D
|
| 251 |
-
.youtube.com TRUE / TRUE 1772413113 __Secure-ROLLOUT_TOKEN CKPJ4ZHJ2ajAZhD82ZLUsbuPAxjFtqHUsbuPAw%3D%3D"""
|
| 252 |
|
| 253 |
try:
|
| 254 |
# Show progress message
|
|
@@ -258,7 +275,7 @@ def extract_youtube_stream_url(url: str, cookies_path: str | None = None) -> str
|
|
| 258 |
|
| 259 |
# First try with provided cookies if available
|
| 260 |
if cookies_path and Path(cookies_path).exists():
|
| 261 |
-
st.info("Using provided cookies for YouTube authentication...")
|
| 262 |
for fmt in format_options:
|
| 263 |
cmd = [
|
| 264 |
ytdlp_path,
|
|
@@ -286,181 +303,181 @@ def extract_youtube_stream_url(url: str, cookies_path: str | None = None) -> str
|
|
| 286 |
else:
|
| 287 |
st.warning(f"yt-dlp failed with format {fmt}: {result.stderr}")
|
| 288 |
|
| 289 |
-
# Try with hardcoded cookies as fallback
|
| 290 |
-
st.info("Trying with hardcoded cookies for YouTube authentication...")
|
| 291 |
-
with tempfile.NamedTemporaryFile(
|
| 292 |
-
|
| 293 |
-
) as temp_cookies:
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
try:
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
finally:
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
# Try with browser cookies (Chrome, Firefox, Safari)
|
| 334 |
-
st.info("Trying to use browser cookies for YouTube authentication...")
|
| 335 |
-
browsers = ["chrome", "firefox", "safari", "edge"]
|
| 336 |
-
|
| 337 |
-
for browser in browsers:
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
# Try with additional yt-dlp options for better compatibility
|
| 370 |
-
st.info("Trying with enhanced compatibility options...")
|
| 371 |
-
for fmt in format_options:
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
# Try with live stream specific options
|
| 407 |
-
st.info("Trying with live stream specific options...")
|
| 408 |
-
for fmt in format_options:
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
# Try without cookies (might work for some videos)
|
| 439 |
-
st.info("Trying without authentication cookies...")
|
| 440 |
-
for fmt in format_options:
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
|
| 465 |
except subprocess.TimeoutExpired:
|
| 466 |
st.error(
|
|
@@ -471,36 +488,36 @@ def extract_youtube_stream_url(url: str, cookies_path: str | None = None) -> str
|
|
| 471 |
except Exception as e:
|
| 472 |
st.error(f"Error extracting YouTube stream URL: {e!s}")
|
| 473 |
|
| 474 |
-
# Show helpful error message with instructions
|
| 475 |
-
st.error("""
|
| 476 |
-
**YouTube Live Stream Authentication Required**
|
| 477 |
-
|
| 478 |
-
YouTube is blocking access to this live stream. This is common for live content due to bot detection.
|
| 479 |
-
|
| 480 |
-
**🔧 Solutions (try in order):**
|
| 481 |
-
|
| 482 |
-
**1. Upload YouTube Cookies (Recommended)**
|
| 483 |
-
- Install browser extension: "Get cookies.txt" or "cookies.txt"
|
| 484 |
-
- Go to YouTube.com and log in
|
| 485 |
-
- Export cookies to cookies.txt file
|
| 486 |
-
- Upload the file using the uploader above
|
| 487 |
-
|
| 488 |
-
**2. Browser Authentication**
|
| 489 |
-
- Make sure you're logged into YouTube in Chrome, Firefox, Safari, or Edge
|
| 490 |
-
- The app will try to use your browser cookies automatically
|
| 491 |
-
|
| 492 |
-
**3. Alternative Live Streams**
|
| 493 |
-
- Try different YouTube live streams (some are more accessible than others)
|
| 494 |
-
- Live streams may have different access restrictions
|
| 495 |
-
|
| 496 |
-
**4. Check Stream Status**
|
| 497 |
-
- Ensure the live stream is actually live and not ended
|
| 498 |
-
- Some streams may be region-restricted
|
| 499 |
-
|
| 500 |
-
**💡 Pro Tip:** Live streams often require authentication more than regular videos.
|
| 501 |
-
""")
|
| 502 |
|
| 503 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
|
| 505 |
|
| 506 |
@st.cache_resource
|
|
|
|
| 89 |
# Render device information
|
| 90 |
model_manager.render_device_info()
|
| 91 |
|
| 92 |
+
# st.sidebar.markdown("---")
|
| 93 |
+
# st.sidebar.header("YouTube Live Streams")
|
| 94 |
|
| 95 |
# Show helpful info about live streams
|
| 96 |
+
# with st.sidebar.expander("ℹ️ About Live Streams", expanded=False):
|
| 97 |
+
# st.markdown("""
|
| 98 |
+
# **Live streams may require authentication:**
|
| 99 |
+
|
| 100 |
+
# 🔐 **Authentication Methods:**
|
| 101 |
+
# - Upload cookies.txt file (recommended)
|
| 102 |
+
# - Browser cookies (Chrome/Firefox/Safari/Edge)
|
| 103 |
+
|
| 104 |
+
# 📺 **Available Live Streams:**
|
| 105 |
+
# - Time Square Live Stream
|
| 106 |
+
# - Dublin Live Stream
|
| 107 |
+
# - Tokyo Live Stream
|
| 108 |
+
# - Abbey Road Live Stream
|
| 109 |
+
|
| 110 |
+
# ⚠️ **Note:** Live streams have stricter access controls than regular videos.
|
| 111 |
+
# """)
|
| 112 |
+
|
| 113 |
+
# st.sidebar.markdown("---")
|
| 114 |
+
# st.sidebar.header("YouTube cookies (optional)")
|
| 115 |
+
cookies_file = (
|
| 116 |
+
Path(__file__).resolve().parents[1]
|
| 117 |
+
/ "resources"
|
| 118 |
+
/ "cookies"
|
| 119 |
+
/ "www.youtube.com_cookies (1).txt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
)
|
| 121 |
+
# st.file_uploader(""
|
| 122 |
+
# "Upload YouTube cookies.txt (optional)",
|
| 123 |
+
# type=["txt"],
|
| 124 |
+
# key="yt_cookies_upload",
|
| 125 |
+
# help=(
|
| 126 |
+
# "**Required if YouTube blocks video access:**\n\n"
|
| 127 |
+
# "1. Install browser extension: 'Get cookies.txt' or 'cookies.txt'\n"
|
| 128 |
+
# "2. Go to YouTube.com and log in\n"
|
| 129 |
+
# "3. Export cookies to cookies.txt file\n"
|
| 130 |
+
# "4. Upload the file here\n\n"
|
| 131 |
+
# "**Alternative:** Make sure you're logged into YouTube in Chrome/Firefox/Safari/Edge\n\n"
|
| 132 |
+
# "⚠️ Keep cookies private; they contain your login session"
|
| 133 |
+
# ),
|
| 134 |
+
# )
|
| 135 |
|
| 136 |
if cookies_file is not None:
|
| 137 |
try:
|
| 138 |
+
# Handle both Path objects and Streamlit UploadedFile objects
|
| 139 |
+
if hasattr(cookies_file, "getvalue"):
|
| 140 |
+
# Streamlit UploadedFile object
|
| 141 |
+
cookie_bytes = cookies_file.getvalue()
|
| 142 |
+
if cookie_bytes:
|
| 143 |
+
cookie_hash = hashlib.sha256(cookie_bytes).hexdigest()[:16]
|
| 144 |
+
cookie_path_obj = (
|
| 145 |
+
Path(tempfile.gettempdir()) / f"yt_cookies_{cookie_hash}.txt"
|
| 146 |
+
)
|
| 147 |
+
cookie_path_obj.write_bytes(cookie_bytes)
|
| 148 |
+
cookies_path = str(cookie_path_obj)
|
| 149 |
+
else:
|
| 150 |
+
cookies_path = None
|
| 151 |
+
st.warning("Uploaded cookies file is empty; ignoring it.")
|
| 152 |
else:
|
| 153 |
+
# Path object - use directly
|
| 154 |
+
if cookies_file.exists():
|
| 155 |
+
cookies_path = str(cookies_file)
|
| 156 |
+
# st.info(f"Using cookies file: {cookies_file.name}")
|
| 157 |
+
else:
|
| 158 |
+
cookies_path = None
|
| 159 |
+
st.warning(f"Cookies file not found: {cookies_file}")
|
| 160 |
except Exception as exc:
|
| 161 |
cookies_path = None
|
| 162 |
+
st.error(f"Failed to process cookies file: {exc!s}")
|
| 163 |
else:
|
| 164 |
cookies_path = None
|
| 165 |
|
|
|
|
| 258 |
st.error("yt-dlp found but not working properly.")
|
| 259 |
return None
|
| 260 |
|
| 261 |
+
# # Hardcoded cookies as fallback (from your provided cookies.txt)
|
| 262 |
+
# hardcoded_cookies = """# Netscape HTTP Cookie File
|
| 263 |
+
# # https://curl.haxx.se/rfc/cookie_spec.html
|
| 264 |
+
# # This is a generated file! Do not edit.
|
| 265 |
|
| 266 |
+
# .youtube.com TRUE / TRUE 1776851748 VISITOR_INFO1_LIVE m4CAb_qRhZM
|
| 267 |
+
# .youtube.com TRUE / TRUE 1776851748 VISITOR_PRIVACY_METADATA CgJBVRIEGgAgQw%3D%3D
|
| 268 |
+
# .youtube.com TRUE / TRUE 1772413113 __Secure-ROLLOUT_TOKEN CKPJ4ZHJ2ajAZhD82ZLUsbuPAxjFtqHUsbuPAw%3D%3D"""
|
| 269 |
|
| 270 |
try:
|
| 271 |
# Show progress message
|
|
|
|
| 275 |
|
| 276 |
# First try with provided cookies if available
|
| 277 |
if cookies_path and Path(cookies_path).exists():
|
| 278 |
+
# st.info("Using provided cookies for YouTube authentication...")
|
| 279 |
for fmt in format_options:
|
| 280 |
cmd = [
|
| 281 |
ytdlp_path,
|
|
|
|
| 303 |
else:
|
| 304 |
st.warning(f"yt-dlp failed with format {fmt}: {result.stderr}")
|
| 305 |
|
| 306 |
+
# # Try with hardcoded cookies as fallback
|
| 307 |
+
# st.info("Trying with hardcoded cookies for YouTube authentication...")
|
| 308 |
+
# with tempfile.NamedTemporaryFile(
|
| 309 |
+
# mode="w", suffix=".txt", delete=False
|
| 310 |
+
# ) as temp_cookies:
|
| 311 |
+
# temp_cookies.write(hardcoded_cookies)
|
| 312 |
+
# temp_cookies_path = temp_cookies.name
|
| 313 |
+
|
| 314 |
+
# try:
|
| 315 |
+
# for fmt in format_options:
|
| 316 |
+
# cmd = [
|
| 317 |
+
# ytdlp_path,
|
| 318 |
+
# "--get-url",
|
| 319 |
+
# "--format",
|
| 320 |
+
# fmt,
|
| 321 |
+
# "--no-playlist",
|
| 322 |
+
# "--no-warnings",
|
| 323 |
+
# "--cookies",
|
| 324 |
+
# temp_cookies_path,
|
| 325 |
+
# url,
|
| 326 |
+
# ]
|
| 327 |
+
|
| 328 |
+
# result = subprocess.run(
|
| 329 |
+
# cmd, check=False, capture_output=True, text=True, timeout=30
|
| 330 |
+
# )
|
| 331 |
+
|
| 332 |
+
# if result.returncode == 0:
|
| 333 |
+
# stream_url = result.stdout.strip()
|
| 334 |
+
# if stream_url and stream_url.startswith("http"):
|
| 335 |
+
# st.success(
|
| 336 |
+
# f"Successfully extracted YouTube stream URL with hardcoded cookies! (format: {fmt})"
|
| 337 |
+
# )
|
| 338 |
+
# return stream_url
|
| 339 |
+
# else:
|
| 340 |
+
# st.warning(
|
| 341 |
+
# f"Hardcoded cookies failed with format {fmt}: {result.stderr[:100]}..."
|
| 342 |
+
# )
|
| 343 |
+
# finally:
|
| 344 |
+
# # Clean up temporary file
|
| 345 |
+
# try:
|
| 346 |
+
# Path(temp_cookies_path).unlink()
|
| 347 |
+
# except:
|
| 348 |
+
# pass
|
| 349 |
+
|
| 350 |
+
# # Try with browser cookies (Chrome, Firefox, Safari)
|
| 351 |
+
# st.info("Trying to use browser cookies for YouTube authentication...")
|
| 352 |
+
# browsers = ["chrome", "firefox", "safari", "edge"]
|
| 353 |
+
|
| 354 |
+
# for browser in browsers:
|
| 355 |
+
# for fmt in format_options:
|
| 356 |
+
# cmd = [
|
| 357 |
+
# ytdlp_path,
|
| 358 |
+
# "--get-url",
|
| 359 |
+
# "--format",
|
| 360 |
+
# fmt,
|
| 361 |
+
# "--no-playlist",
|
| 362 |
+
# "--no-warnings",
|
| 363 |
+
# "--cookies-from-browser",
|
| 364 |
+
# browser,
|
| 365 |
+
# url,
|
| 366 |
+
# ]
|
| 367 |
+
|
| 368 |
+
# result = subprocess.run(
|
| 369 |
+
# cmd, check=False, capture_output=True, text=True, timeout=30
|
| 370 |
+
# )
|
| 371 |
+
|
| 372 |
+
# if result.returncode == 0:
|
| 373 |
+
# stream_url = result.stdout.strip()
|
| 374 |
+
# if stream_url and stream_url.startswith("http"):
|
| 375 |
+
# st.success(
|
| 376 |
+
# f"Successfully extracted YouTube stream URL using {browser} cookies! (format: {fmt})"
|
| 377 |
+
# )
|
| 378 |
+
# return stream_url
|
| 379 |
+
# else:
|
| 380 |
+
# # Only show warning for the first browser attempt
|
| 381 |
+
# if fmt == format_options[0]:
|
| 382 |
+
# st.warning(
|
| 383 |
+
# f"Failed to use {browser} cookies: {result.stderr[:100]}..."
|
| 384 |
+
# )
|
| 385 |
+
|
| 386 |
+
# # Try with additional yt-dlp options for better compatibility
|
| 387 |
+
# st.info("Trying with enhanced compatibility options...")
|
| 388 |
+
# for fmt in format_options:
|
| 389 |
+
# cmd = [
|
| 390 |
+
# ytdlp_path,
|
| 391 |
+
# "--get-url",
|
| 392 |
+
# "--format",
|
| 393 |
+
# fmt,
|
| 394 |
+
# "--no-playlist",
|
| 395 |
+
# "--no-warnings",
|
| 396 |
+
# "--user-agent",
|
| 397 |
+
# "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
| 398 |
+
# "--referer",
|
| 399 |
+
# "https://www.youtube.com/",
|
| 400 |
+
# "--add-header",
|
| 401 |
+
# "Accept-Language:en-US,en;q=0.9",
|
| 402 |
+
# "--add-header",
|
| 403 |
+
# "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
| 404 |
+
# url,
|
| 405 |
+
# ]
|
| 406 |
+
|
| 407 |
+
# result = subprocess.run(
|
| 408 |
+
# cmd, check=False, capture_output=True, text=True, timeout=30
|
| 409 |
+
# )
|
| 410 |
+
|
| 411 |
+
# if result.returncode == 0:
|
| 412 |
+
# stream_url = result.stdout.strip()
|
| 413 |
+
# if stream_url and stream_url.startswith("http"):
|
| 414 |
+
# st.success(
|
| 415 |
+
# f"Successfully extracted YouTube stream URL with enhanced options! (format: {fmt})"
|
| 416 |
+
# )
|
| 417 |
+
# return stream_url
|
| 418 |
+
# else:
|
| 419 |
+
# st.warning(
|
| 420 |
+
# f"Enhanced options failed with format {fmt}: {result.stderr[:100]}..."
|
| 421 |
+
# )
|
| 422 |
+
|
| 423 |
+
# # Try with live stream specific options
|
| 424 |
+
# st.info("Trying with live stream specific options...")
|
| 425 |
+
# for fmt in format_options:
|
| 426 |
+
# cmd = [
|
| 427 |
+
# ytdlp_path,
|
| 428 |
+
# "--get-url",
|
| 429 |
+
# "--format",
|
| 430 |
+
# fmt,
|
| 431 |
+
# "--no-playlist",
|
| 432 |
+
# "--no-warnings",
|
| 433 |
+
# "--live-from-start",
|
| 434 |
+
# "--user-agent",
|
| 435 |
+
# "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
| 436 |
+
# url,
|
| 437 |
+
# ]
|
| 438 |
+
|
| 439 |
+
# result = subprocess.run(
|
| 440 |
+
# cmd, check=False, capture_output=True, text=True, timeout=30
|
| 441 |
+
# )
|
| 442 |
+
|
| 443 |
+
# if result.returncode == 0:
|
| 444 |
+
# stream_url = result.stdout.strip()
|
| 445 |
+
# if stream_url and stream_url.startswith("http"):
|
| 446 |
+
# st.success(
|
| 447 |
+
# f"Successfully extracted YouTube live stream URL! (format: {fmt})"
|
| 448 |
+
# )
|
| 449 |
+
# return stream_url
|
| 450 |
+
# else:
|
| 451 |
+
# st.warning(
|
| 452 |
+
# f"Live stream options failed with format {fmt}: {result.stderr[:100]}..."
|
| 453 |
+
# )
|
| 454 |
+
|
| 455 |
+
# # Try without cookies (might work for some videos)
|
| 456 |
+
# st.info("Trying without authentication cookies...")
|
| 457 |
+
# for fmt in format_options:
|
| 458 |
+
# cmd = [
|
| 459 |
+
# ytdlp_path,
|
| 460 |
+
# "--get-url",
|
| 461 |
+
# "--format",
|
| 462 |
+
# fmt,
|
| 463 |
+
# "--no-playlist",
|
| 464 |
+
# "--no-warnings",
|
| 465 |
+
# url,
|
| 466 |
+
# ]
|
| 467 |
+
|
| 468 |
+
# result = subprocess.run(
|
| 469 |
+
# cmd, check=False, capture_output=True, text=True, timeout=30
|
| 470 |
+
# )
|
| 471 |
+
|
| 472 |
+
# if result.returncode == 0:
|
| 473 |
+
# stream_url = result.stdout.strip()
|
| 474 |
+
# if stream_url and stream_url.startswith("http"):
|
| 475 |
+
# st.success(
|
| 476 |
+
# f"Successfully extracted YouTube stream URL without cookies! (format: {fmt})"
|
| 477 |
+
# )
|
| 478 |
+
# return stream_url
|
| 479 |
+
# else:
|
| 480 |
+
# st.warning(f"yt-dlp failed with format {fmt}: {result.stderr}")
|
| 481 |
|
| 482 |
except subprocess.TimeoutExpired:
|
| 483 |
st.error(
|
|
|
|
| 488 |
except Exception as e:
|
| 489 |
st.error(f"Error extracting YouTube stream URL: {e!s}")
|
| 490 |
|
| 491 |
+
# # Show helpful error message with instructions
|
| 492 |
+
# st.error("""
|
| 493 |
+
# **YouTube Live Stream Authentication Required**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 494 |
|
| 495 |
+
# YouTube is blocking access to this live stream. This is common for live content due to bot detection.
|
| 496 |
+
|
| 497 |
+
# **🔧 Solutions (try in order):**
|
| 498 |
+
|
| 499 |
+
# **1. Upload YouTube Cookies (Recommended)**
|
| 500 |
+
# - Install browser extension: "Get cookies.txt" or "cookies.txt"
|
| 501 |
+
# - Go to YouTube.com and log in
|
| 502 |
+
# - Export cookies to cookies.txt file
|
| 503 |
+
# - Upload the file using the uploader above
|
| 504 |
+
|
| 505 |
+
# **2. Browser Authentication**
|
| 506 |
+
# - Make sure you're logged into YouTube in Chrome, Firefox, Safari, or Edge
|
| 507 |
+
# - The app will try to use your browser cookies automatically
|
| 508 |
+
|
| 509 |
+
# **3. Alternative Live Streams**
|
| 510 |
+
# - Try different YouTube live streams (some are more accessible than others)
|
| 511 |
+
# - Live streams may have different access restrictions
|
| 512 |
+
|
| 513 |
+
# **4. Check Stream Status**
|
| 514 |
+
# - Ensure the live stream is actually live and not ended
|
| 515 |
+
# - Some streams may be region-restricted
|
| 516 |
+
|
| 517 |
+
# **💡 Pro Tip:** Live streams often require authentication more than regular videos.
|
| 518 |
+
# """)
|
| 519 |
+
|
| 520 |
+
# return None
|
| 521 |
|
| 522 |
|
| 523 |
@st.cache_resource
|
services/app_service/resources/cookies/www.youtube.com_cookies (1).txt
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Netscape HTTP Cookie File
|
| 2 |
+
# This file is generated by yt-dlp. Do not edit.
|
| 3 |
+
|
| 4 |
+
.youtube.com TRUE / FALSE 0 PREF tz=UTC&f6=40000000&hl=en
|
| 5 |
+
.youtube.com TRUE / TRUE 1792836052 __Secure-1PSIDTS sidts-CjQBmkD5SzQ-QildxkPJNTtx1TUvEWqcjRTZPatd-nGd8Y386CE7MKL4-tYPqmdxpknkDy90EAA
|
| 6 |
+
.youtube.com TRUE / TRUE 1792836052 __Secure-3PSIDTS sidts-CjQBmkD5SzQ-QildxkPJNTtx1TUvEWqcjRTZPatd-nGd8Y386CE7MKL4-tYPqmdxpknkDy90EAA
|
| 7 |
+
.youtube.com TRUE / FALSE 1795860052 HSID A3SnRh5yXhPgQj3jU
|
| 8 |
+
.youtube.com TRUE / TRUE 1795860052 SSID AfYeK89Eh4QoicIAz
|
| 9 |
+
.youtube.com TRUE / FALSE 1795860052 APISID FHikac5HDeOP910d/AXixS5KqsEGYcEYh3
|
| 10 |
+
.youtube.com TRUE / TRUE 1795860052 SAPISID g0Nyl1SXHk8UmNjO/AyfgTxBuPDkNJzVq_
|
| 11 |
+
.youtube.com TRUE / TRUE 1795860052 __Secure-1PAPISID g0Nyl1SXHk8UmNjO/AyfgTxBuPDkNJzVq_
|
| 12 |
+
.youtube.com TRUE / TRUE 1795860052 __Secure-3PAPISID g0Nyl1SXHk8UmNjO/AyfgTxBuPDkNJzVq_
|
| 13 |
+
.youtube.com TRUE / FALSE 1795860052 SID g.a0002wgrpcW9K-QNYioDxFejw3GZD9efUs0mRhFq3acAXjra01CO9jm6rm6neNpvv4fnHs-BRgACgYKAfoSARUSFQHGX2Mi6DjvUvouyeTF3GCpZVZfzhoVAUF8yKr7kGA8CQoXW3beRbyA3kOb0076
|
| 14 |
+
.youtube.com TRUE / TRUE 1795860052 __Secure-1PSID g.a0002wgrpcW9K-QNYioDxFejw3GZD9efUs0mRhFq3acAXjra01COElc9yIf8E5lZjcmehkOAoAACgYKATYSARUSFQHGX2MiWlVwx7WCXoMqEpE8OPe6uBoVAUF8yKoNXCEYEM1OaXvtmwgRgVk50076
|
| 15 |
+
.youtube.com TRUE / TRUE 1795860052 __Secure-3PSID g.a0002wgrpcW9K-QNYioDxFejw3GZD9efUs0mRhFq3acAXjra01COIiAEqiDC2XZPFcs_RH2U7AACgYKAfYSARUSFQHGX2Mi0KLOQQs0Au5u5xYXwmfaBhoVAUF8yKqN132DDK9He9JDLUX1bEz10076
|
| 16 |
+
.youtube.com TRUE / TRUE 1795860053 LOGIN_INFO AFmmF2swRAIgRKXvUyDr8P18ZQwmyUgxyKGvHjNBMkeIsGSaWm76WDACIG2OvtxNgjffm-ENPsSwdsv6sn1Rv3OLmUXY8uVhCzEF:QUQ3MjNmeWxRMkNvOEtZejh3VEVRRGxlazNMY3hEa0Zhc0dUcl9vTlVFZWtDdk5PX2laWWpvLWE0WngxbW9oYlNQRzFackoxeUpmTkx5SGtsWW9kUXl4eFo1ZUphTVFiYkhlRGxsTksyUUZkRnBBbTNDWWFVLUdlS09QaUVyUU1SVEtVOVNaOElJSFl5X2JPS09TT2JSQkswelFSaW43TVln
|
| 17 |
+
.youtube.com TRUE / FALSE 1792920739 SIDCC AKEyXzW06eq17IREQE1YpeawZS7Xa8VOxgAQJe5ogQDXrH2X_HX6csXif5MPKudlLNV0g_yZOQ
|
| 18 |
+
.youtube.com TRUE / TRUE 1792920739 __Secure-1PSIDCC AKEyXzXYWJ8Le-m3RpwLkOHpv4re7wXkDZNW8LTg-kARYQHTz88O0LwvHOD-7jEIjvloL7wD
|
| 19 |
+
.youtube.com TRUE / TRUE 1792920739 __Secure-3PSIDCC AKEyXzWan5j7VlHwqr44sRfhD68FDzPlqvZMYq4GB-pJuzzuFKaoLSoRyh9ATyNl14Twjj64gQ
|
| 20 |
+
.youtube.com TRUE / TRUE 0 YSC JNOzy0pmT_0
|
| 21 |
+
.youtube.com TRUE / TRUE 1776936739 VISITOR_INFO1_LIVE y1BPxdbbDNs
|
| 22 |
+
.youtube.com TRUE / TRUE 1776936739 VISITOR_PRIVACY_METADATA CgJBVRIEGgAgJw%3D%3D
|
| 23 |
+
.youtube.com TRUE / TRUE 1776851773 __Secure-ROLLOUT_TOKEN CMDh2N6P_q_XIBDpoLH5yLyQAxjDxsX6yLyQAw%3D%3D
|
| 24 |
+
.youtube.com TRUE / TRUE 1824456739 __Secure-YT_TVFAS t=489249&s=2
|
| 25 |
+
.youtube.com TRUE / TRUE 1776936739 DEVICE_INFO ChxOelUyTlRBNE56VXlNek0xTnpBek16QTVOdz09EKOy8scGGIWu8scG
|
| 26 |
+
.youtube.com TRUE /tv TRUE 1794216739 __Secure-YT_DERP CPjNrY5_
|