dfd
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
This commit is contained in:
@@ -363,23 +363,24 @@ class DownloadModal(ModalScreen):
|
||||
self.app.call_from_thread(self._hide_progress)
|
||||
return
|
||||
|
||||
# Stage 1: Download data if enabled
|
||||
# Stage 1: Download if enabled
|
||||
download_succeeded = False
|
||||
download_stderr_text = "" # Store for merge stage
|
||||
if download_enabled:
|
||||
download_cmdlet = get_cmdlet("download-data")
|
||||
download_cmdlet_name = "download-media" if self.is_playlist else "download-file"
|
||||
download_cmdlet = get_cmdlet(download_cmdlet_name)
|
||||
if download_cmdlet:
|
||||
logger.info("📥 Executing download-data stage")
|
||||
logger.info(f"📥 Executing {download_cmdlet_name} stage")
|
||||
logger.info(f"download_cmdlet object: {download_cmdlet}")
|
||||
logger.info(f"result_obj: {result_obj}")
|
||||
|
||||
# Log step to worker
|
||||
if worker:
|
||||
worker.log_step("Starting download-data stage...")
|
||||
worker.log_step(f"Starting {download_cmdlet_name} stage...")
|
||||
|
||||
# Build arguments for download-data
|
||||
# Build arguments for download-media (yt-dlp) playlists; download-file takes no yt-dlp args.
|
||||
cmdlet_args = []
|
||||
if self.is_playlist:
|
||||
if download_cmdlet_name == "download-media" and self.is_playlist:
|
||||
# Always use yt-dlp's native --playlist-items for playlists
|
||||
if playlist_selection:
|
||||
# User provided specific selection
|
||||
@@ -415,7 +416,10 @@ class DownloadModal(ModalScreen):
|
||||
try:
|
||||
with redirect_stdout(stdout_buf), redirect_stderr(stderr_buf):
|
||||
logger.info(f"Calling download_cmdlet...")
|
||||
returncode = download_cmdlet(result_obj, cmdlet_args, self.config)
|
||||
cmd_config = dict(self.config) if isinstance(self.config, dict) else self.config
|
||||
if isinstance(cmd_config, dict):
|
||||
cmd_config["_quiet_background_output"] = True
|
||||
returncode = download_cmdlet(result_obj, cmdlet_args, cmd_config)
|
||||
logger.info(f"download_cmdlet returned: {returncode}")
|
||||
except Exception as cmdlet_error:
|
||||
# If cmdlet throws an exception, log it
|
||||
@@ -437,17 +441,17 @@ class DownloadModal(ModalScreen):
|
||||
# Always append output to worker for debugging
|
||||
if worker:
|
||||
if stdout_text:
|
||||
worker.append_stdout(f"[download-data stdout]\n{stdout_text}\n")
|
||||
worker.append_stdout(f"[{download_cmdlet_name} stdout]\n{stdout_text}\n")
|
||||
if stderr_text:
|
||||
worker.append_stdout(f"[download-data stderr]\n{stderr_text}\n")
|
||||
worker.append_stdout(f"[{download_cmdlet_name} stderr]\n{stderr_text}\n")
|
||||
|
||||
# Log the output so it gets captured by WorkerLoggingHandler
|
||||
if stdout_text:
|
||||
logger.info(f"[download-data output]\n{stdout_text}")
|
||||
logger.info(f"[{download_cmdlet_name} output]\n{stdout_text}")
|
||||
if stderr_text:
|
||||
logger.info(f"[download-data stderr]\n{stderr_text}")
|
||||
logger.info(f"[{download_cmdlet_name} stderr]\n{stderr_text}")
|
||||
if returncode != 0:
|
||||
download_failed_msg = f"❌ download-data stage failed with code {returncode}\nstdout: {stdout_text}\nstderr: {stderr_text}"
|
||||
download_failed_msg = f"❌ {download_cmdlet_name} stage failed with code {returncode}\nstdout: {stdout_text}\nstderr: {stderr_text}"
|
||||
logger.error(download_failed_msg)
|
||||
if worker:
|
||||
worker.append_stdout(f"\n{download_failed_msg}\n")
|
||||
@@ -545,11 +549,11 @@ class DownloadModal(ModalScreen):
|
||||
else:
|
||||
download_succeeded = True
|
||||
# Always log output at INFO level so we can see what happened
|
||||
logger.info(f"download-data stage completed successfully")
|
||||
logger.info(f"{download_cmdlet_name} stage completed successfully")
|
||||
if stdout_text:
|
||||
logger.info(f"download-data stdout:\n{stdout_text}")
|
||||
logger.info(f"{download_cmdlet_name} stdout:\n{stdout_text}")
|
||||
if stderr_text:
|
||||
logger.info(f"download-data stderr:\n{stderr_text}")
|
||||
logger.info(f"{download_cmdlet_name} stderr:\n{stderr_text}")
|
||||
|
||||
# Log step to worker
|
||||
if worker:
|
||||
@@ -630,9 +634,9 @@ class DownloadModal(ModalScreen):
|
||||
logger.info(f"Merge enabled - will merge {len(downloaded_files)} files before tagging")
|
||||
download_stderr_text = f"DOWNLOADED_FILES:{','.join(downloaded_files)}\n" + download_stderr_text
|
||||
|
||||
logger.info("download-data stage completed successfully")
|
||||
logger.info(f"{download_cmdlet_name} stage completed successfully")
|
||||
except Exception as e:
|
||||
logger.error(f"download-data execution error: {e}", exc_info=True)
|
||||
logger.error(f"{download_cmdlet_name} execution error: {e}", exc_info=True)
|
||||
self.app.call_from_thread(
|
||||
self.app.notify,
|
||||
f"Download error: {e}",
|
||||
@@ -1577,9 +1581,10 @@ class DownloadModal(ModalScreen):
|
||||
|
||||
# Stage 1: Download data if enabled
|
||||
if download_enabled:
|
||||
download_cmdlet = get_cmdlet("download-data")
|
||||
download_cmdlet_name = "download-file"
|
||||
download_cmdlet = get_cmdlet(download_cmdlet_name)
|
||||
if download_cmdlet:
|
||||
stage_msg = "📥 Executing download-data stage"
|
||||
stage_msg = f"📥 Executing {download_cmdlet_name} stage"
|
||||
logger.info(stage_msg)
|
||||
if worker:
|
||||
worker.append_stdout(f"{stage_msg}\n")
|
||||
@@ -1591,23 +1596,26 @@ class DownloadModal(ModalScreen):
|
||||
stderr_buf = io.StringIO()
|
||||
|
||||
with redirect_stdout(stdout_buf), redirect_stderr(stderr_buf):
|
||||
returncode = download_cmdlet(result_obj, [], self.config)
|
||||
cmd_config = dict(self.config) if isinstance(self.config, dict) else self.config
|
||||
if isinstance(cmd_config, dict):
|
||||
cmd_config["_quiet_background_output"] = True
|
||||
returncode = download_cmdlet(result_obj, [], cmd_config)
|
||||
|
||||
stdout_text = stdout_buf.getvalue()
|
||||
stderr_text = stderr_buf.getvalue()
|
||||
|
||||
if stdout_text:
|
||||
logger.debug(f"download-data stdout: {stdout_text}")
|
||||
logger.debug(f"{download_cmdlet_name} stdout: {stdout_text}")
|
||||
if worker:
|
||||
worker.append_stdout(stdout_text)
|
||||
|
||||
if stderr_text:
|
||||
logger.debug(f"download-data stderr: {stderr_text}")
|
||||
logger.debug(f"{download_cmdlet_name} stderr: {stderr_text}")
|
||||
if worker:
|
||||
worker.append_stdout(f"⚠️ stderr: {stderr_text}\n")
|
||||
|
||||
if returncode != 0:
|
||||
error_msg = f"❌ download-data stage failed with code {returncode}\nstderr: {stderr_text}"
|
||||
error_msg = f"❌ {download_cmdlet_name} stage failed with code {returncode}\nstderr: {stderr_text}"
|
||||
logger.error(error_msg)
|
||||
if worker:
|
||||
worker.append_stdout(f"{error_msg}\n")
|
||||
@@ -1619,12 +1627,12 @@ class DownloadModal(ModalScreen):
|
||||
)
|
||||
return
|
||||
else:
|
||||
success_msg = "download-data completed successfully"
|
||||
success_msg = f"{download_cmdlet_name} completed successfully"
|
||||
logger.info(success_msg)
|
||||
if worker:
|
||||
worker.append_stdout(f"{success_msg}\n")
|
||||
except Exception as e:
|
||||
error_msg = f"❌ download-data error: {e}"
|
||||
error_msg = f"❌ {download_cmdlet_name} error: {e}"
|
||||
logger.error(error_msg, exc_info=True)
|
||||
if worker:
|
||||
worker.append_stdout(f"{error_msg}\nTraceback:\n{__import__('traceback').format_exc()}\n")
|
||||
|
||||
Reference in New Issue
Block a user