d
This commit is contained in:
@@ -1203,11 +1203,29 @@ class AllDebrid(TableProviderMixin, Provider):
|
|||||||
log(f"AllDebrid magnet {magnet_id} has no files", file=sys.stderr)
|
log(f"AllDebrid magnet {magnet_id} has no files", file=sys.stderr)
|
||||||
return 0
|
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
|
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()
|
locked_url = str(node.get("l") or node.get("link") or "").strip()
|
||||||
file_name = str(node.get("n") or node.get("name") or "").strip()
|
file_name = str(node.get("n") or node.get("name") or "").strip()
|
||||||
relpath = str(node.get("_relpath") or file_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:
|
if not locked_url or not relpath:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -1329,7 +1329,11 @@ class PipelineExecutor:
|
|||||||
# This executor is used by both the REPL and the `pipeline` subcommand.
|
# This executor is used by both the REPL and the `pipeline` subcommand.
|
||||||
# Quiet/background mode is helpful for detached/background runners, but
|
# Quiet/background mode is helpful for detached/background runners, but
|
||||||
# it suppresses interactive UX (like the pipeline Live progress UI).
|
# 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
|
return config
|
||||||
|
|
||||||
@staticmethod
|
@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))
|
logger.exception("Failed to record pipeline log step for applied row action (pipeline_session=%r)", getattr(pipeline_session, 'worker_id', None))
|
||||||
else:
|
else:
|
||||||
first_cmd = stages[0][0] if stages and stages[0] else None
|
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 (
|
if isinstance(table_type, str) and table_type.startswith("metadata.") and first_cmd not in (
|
||||||
"get-tag",
|
"get-tag",
|
||||||
"get_tag",
|
"get_tag",
|
||||||
@@ -2204,7 +2239,7 @@ class PipelineExecutor:
|
|||||||
print("Auto-inserting get-tag after metadata selection")
|
print("Auto-inserting get-tag after metadata selection")
|
||||||
stages.insert(0, ["get-tag"])
|
stages.insert(0, ["get-tag"])
|
||||||
elif auto_stage:
|
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])
|
auto_cmd_norm = _norm_cmd(auto_stage[0])
|
||||||
if first_cmd_norm not in (auto_cmd_norm, ".pipe", ".mpv"):
|
if first_cmd_norm not in (auto_cmd_norm, ".pipe", ".mpv"):
|
||||||
debug(f"Auto-inserting {auto_cmd_norm} after selection")
|
debug(f"Auto-inserting {auto_cmd_norm} after selection")
|
||||||
|
|||||||
@@ -1037,7 +1037,7 @@ class Download_File(Cmdlet):
|
|||||||
vcodec = str(chosen.get("vcodec", "none"))
|
vcodec = str(chosen.get("vcodec", "none"))
|
||||||
acodec = str(chosen.get("acodec", "none"))
|
acodec = str(chosen.get("acodec", "none"))
|
||||||
if vcodec != "none" and 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:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -1332,7 +1332,7 @@ class Download_File(Cmdlet):
|
|||||||
selection_format_id = format_id
|
selection_format_id = format_id
|
||||||
try:
|
try:
|
||||||
if vcodec != "none" and acodec == "none" and format_id:
|
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:
|
except Exception:
|
||||||
selection_format_id = format_id
|
selection_format_id = format_id
|
||||||
|
|
||||||
@@ -1572,8 +1572,8 @@ class Download_File(Cmdlet):
|
|||||||
vcodec = str(fmt_match.get("vcodec", "none"))
|
vcodec = str(fmt_match.get("vcodec", "none"))
|
||||||
acodec = str(fmt_match.get("acodec", "none"))
|
acodec = str(fmt_match.get("acodec", "none"))
|
||||||
if vcodec != "none" and acodec == "none":
|
if vcodec != "none" and acodec == "none":
|
||||||
debug(f"Selected video-only format {actual_format}; using {actual_format}+ba for audio")
|
debug(f"Selected video-only format {actual_format}; using {actual_format}+bestaudio/best for audio")
|
||||||
actual_format = f"{actual_format}+ba"
|
actual_format = f"{actual_format}+bestaudio/best"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -1718,7 +1718,7 @@ class Download_File(Cmdlet):
|
|||||||
vcodec = str(only.get("vcodec", "none"))
|
vcodec = str(only.get("vcodec", "none"))
|
||||||
acodec = str(only.get("acodec", "none"))
|
acodec = str(only.get("acodec", "none"))
|
||||||
if vcodec != "none" and acodec == "none" and fallback_format:
|
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:
|
except Exception:
|
||||||
selection_format_id = fallback_format
|
selection_format_id = fallback_format
|
||||||
|
|
||||||
@@ -1748,7 +1748,7 @@ class Download_File(Cmdlet):
|
|||||||
selection_format_id = format_id
|
selection_format_id = format_id
|
||||||
try:
|
try:
|
||||||
if vcodec != "none" and acodec == "none" and format_id:
|
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:
|
except Exception:
|
||||||
selection_format_id = format_id
|
selection_format_id = format_id
|
||||||
|
|
||||||
@@ -1823,7 +1823,7 @@ class Download_File(Cmdlet):
|
|||||||
PipelineProgress(pipeline_context).step("awaiting selection")
|
PipelineProgress(pipeline_context).step("awaiting selection")
|
||||||
|
|
||||||
log("Requested format is not available; select a working format with @N", file=sys.stderr)
|
log("Requested format is not available; select a working format with @N", file=sys.stderr)
|
||||||
return 0
|
return 1
|
||||||
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user