feat: enhance chat downloading with stream monitoring and improved file paths
This commit is contained in:
parent
22a1f5b600
commit
b47641feaa
3 changed files with 87 additions and 30 deletions
|
|
@ -20,6 +20,7 @@ from modules.config import ConfigManager
|
|||
from modules.file_manager import FileManager
|
||||
from modules.utils import get_ffmpeg_executable, get_twitch_downloader_executable, detect_operating_system
|
||||
from modules.downloader import ContentDownloader
|
||||
from modules.stream_monitor import StreamMonitor
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -72,12 +73,49 @@ def main():
|
|||
def shutdown_check():
|
||||
return stop_requested['stop']
|
||||
|
||||
# Start thread
|
||||
# Prepare stream monitor
|
||||
stream_monitor = StreamMonitor(args.username)
|
||||
|
||||
# If chat downloads are disabled in config, enter monitoring mode instead
|
||||
if not downloader.download_live_chat:
|
||||
print(f"{Fore.YELLOW}⚠ downloadLiveCHAT is disabled in config - entering monitoring mode for {args.username}{Style.RESET_ALL}")
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
is_live = stream_monitor.is_user_live()
|
||||
if is_live:
|
||||
print(f"{Fore.GREEN}✓ {args.username} is live! Exiting monitor. Run the archiver to record video.{Style.RESET_ALL}")
|
||||
break
|
||||
else:
|
||||
print(f"{Fore.CYAN}{args.username} is offline - checking again in 30s...{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}⚠ Could not check stream status: {e}{Style.RESET_ALL}")
|
||||
time.sleep(30)
|
||||
except KeyboardInterrupt:
|
||||
print('\nKeyboard interrupt received; stopping monitor...')
|
||||
return
|
||||
|
||||
# If chat download is enabled, but the stream is currently offline, wait until it goes live
|
||||
try:
|
||||
try:
|
||||
if not stream_monitor.is_user_live():
|
||||
print(f"{Fore.CYAN}{args.username} is currently offline - waiting for live stream to start...{Style.RESET_ALL}")
|
||||
while not stream_monitor.is_user_live():
|
||||
time.sleep(10)
|
||||
except Exception:
|
||||
# If we cannot determine live status, proceed to start chat downloader anyway
|
||||
pass
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print('\nKeyboard interrupt received; exiting...')
|
||||
return
|
||||
|
||||
# Start thread (stream_monitor passed so downloader can stop when stream ends)
|
||||
thread = downloader.start_chat_downloader_thread(
|
||||
args.username,
|
||||
json_path,
|
||||
shutdown_check=shutdown_check,
|
||||
stream_monitor=None,
|
||||
stream_monitor=stream_monitor,
|
||||
verbose=args.verbose
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue