From 14871a1f0206b73b7ad3dac47958b5a1d2474dc8 Mon Sep 17 00:00:00 2001 From: Nose Date: Sat, 14 Feb 2026 20:39:33 -0800 Subject: [PATCH] d --- Provider/alldebrid.py | 20 +++++++++++++++++++- SYS/pipeline.py | 39 +++++++++++++++++++++++++++++++++++++-- cmdlet/download_file.py | 14 +++++++------- 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/Provider/alldebrid.py b/Provider/alldebrid.py index e9039c3..5d70d98 100644 --- a/Provider/alldebrid.py +++ b/Provider/alldebrid.py @@ -1203,11 +1203,29 @@ class AllDebrid(TableProviderMixin, Provider): log(f"AllDebrid magnet {magnet_id} has no files", file=sys.stderr) return 0 + file_entries = list(self._flatten_files(file_nodes)) + total_files = len(file_entries) + if total_files <= 0: + log(f"AllDebrid magnet {magnet_id} has no downloadable files", file=sys.stderr) + return 0 + + try: + if progress is not None and hasattr(progress, "begin_steps"): + progress.begin_steps(total_files) + except Exception: + pass + downloaded = 0 - for node in self._flatten_files(file_nodes): + for file_idx, node in enumerate(file_entries, 1): locked_url = str(node.get("l") or node.get("link") or "").strip() file_name = str(node.get("n") or node.get("name") or "").strip() relpath = str(node.get("_relpath") or file_name or "").strip() + + try: + if progress is not None and hasattr(progress, "step"): + progress.step(f"file {file_idx}/{total_files}: {relpath or file_name or 'download'}") + except Exception: + pass if not locked_url or not relpath: continue diff --git a/SYS/pipeline.py b/SYS/pipeline.py index bfbfb69..513f299 100644 --- a/SYS/pipeline.py +++ b/SYS/pipeline.py @@ -1329,7 +1329,11 @@ class PipelineExecutor: # This executor is used by both the REPL and the `pipeline` subcommand. # Quiet/background mode is helpful for detached/background runners, but # it suppresses interactive UX (like the pipeline Live progress UI). - config["_quiet_background_output"] = bool(self._toolbar_output is None) + try: + is_tty = bool(getattr(sys.stderr, "isatty", lambda: False)()) + except Exception: + is_tty = False + config["_quiet_background_output"] = not is_tty return config @staticmethod @@ -2195,6 +2199,37 @@ class PipelineExecutor: logger.exception("Failed to record pipeline log step for applied row action (pipeline_session=%r)", getattr(pipeline_session, 'worker_id', None)) else: first_cmd = stages[0][0] if stages and stages[0] else None + first_cmd_norm = _norm_cmd(first_cmd) + + inserted_provider_download = False + if first_cmd_norm == "add-file": + # If selected rows advertise an explicit download-file action, + # run download before add-file so add-file receives local files. + if len(selection_indices) == 1: + row_action = _get_row_action(selection_indices[0], items_list) + if row_action and _norm_cmd(row_action[0]) == "download-file": + stages.insert(0, [str(x) for x in row_action if x is not None]) + inserted_provider_download = True + debug("Auto-inserting row download-file action before add-file") + + # Multi-selection fallback: if any selected row declares a + # download-file action, insert a generic download-file stage. + # This keeps provider-specific behavior in provider metadata. + if (not inserted_provider_download) and len(selection_indices) > 1: + try: + has_download_row_action = False + for idx in selection_indices: + row_action = _get_row_action(idx, items_list) + if row_action and _norm_cmd(row_action[0]) == "download-file": + has_download_row_action = True + break + if has_download_row_action: + stages.insert(0, ["download-file"]) + inserted_provider_download = True + debug("Auto-inserting download-file before add-file for provider selection") + except Exception: + pass + if isinstance(table_type, str) and table_type.startswith("metadata.") and first_cmd not in ( "get-tag", "get_tag", @@ -2204,7 +2239,7 @@ class PipelineExecutor: print("Auto-inserting get-tag after metadata selection") stages.insert(0, ["get-tag"]) elif auto_stage: - first_cmd_norm = _norm_cmd(first_cmd) + first_cmd_norm = _norm_cmd(stages[0][0] if stages and stages[0] else None) auto_cmd_norm = _norm_cmd(auto_stage[0]) if first_cmd_norm not in (auto_cmd_norm, ".pipe", ".mpv"): debug(f"Auto-inserting {auto_cmd_norm} after selection") diff --git a/cmdlet/download_file.py b/cmdlet/download_file.py index 002f62a..19ae045 100644 --- a/cmdlet/download_file.py +++ b/cmdlet/download_file.py @@ -1037,7 +1037,7 @@ class Download_File(Cmdlet): vcodec = str(chosen.get("vcodec", "none")) acodec = str(chosen.get("acodec", "none")) if vcodec != "none" and acodec == "none": - selection_format_id = f"{selection_format_id}+ba" + selection_format_id = f"{selection_format_id}+bestaudio/best" except Exception: pass @@ -1332,7 +1332,7 @@ class Download_File(Cmdlet): selection_format_id = format_id try: if vcodec != "none" and acodec == "none" and format_id: - selection_format_id = f"{format_id}+ba" + selection_format_id = f"{format_id}+bestaudio/best" except Exception: selection_format_id = format_id @@ -1572,8 +1572,8 @@ class Download_File(Cmdlet): vcodec = str(fmt_match.get("vcodec", "none")) acodec = str(fmt_match.get("acodec", "none")) if vcodec != "none" and acodec == "none": - debug(f"Selected video-only format {actual_format}; using {actual_format}+ba for audio") - actual_format = f"{actual_format}+ba" + debug(f"Selected video-only format {actual_format}; using {actual_format}+bestaudio/best for audio") + actual_format = f"{actual_format}+bestaudio/best" except Exception as e: pass @@ -1718,7 +1718,7 @@ class Download_File(Cmdlet): vcodec = str(only.get("vcodec", "none")) acodec = str(only.get("acodec", "none")) if vcodec != "none" and acodec == "none" and fallback_format: - selection_format_id = f"{fallback_format}+ba" + selection_format_id = f"{fallback_format}+bestaudio/best" except Exception: selection_format_id = fallback_format @@ -1748,7 +1748,7 @@ class Download_File(Cmdlet): selection_format_id = format_id try: if vcodec != "none" and acodec == "none" and format_id: - selection_format_id = f"{format_id}+ba" + selection_format_id = f"{format_id}+bestaudio/best" except Exception: selection_format_id = format_id @@ -1823,7 +1823,7 @@ class Download_File(Cmdlet): PipelineProgress(pipeline_context).step("awaiting selection") log("Requested format is not available; select a working format with @N", file=sys.stderr) - return 0 + return 1 raise