alldebrid plugin optimization and mpv playlist fix
This commit is contained in:
+29
-15
@@ -1248,11 +1248,15 @@ class AllDebrid(TableProviderMixin, Provider):
|
||||
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
|
||||
magnet_path_metadata: Dict[str, Any] = {}
|
||||
magnet_folder_name = str(
|
||||
magnet_files.get("filename")
|
||||
or magnet_files.get("name")
|
||||
or magnet_files.get("hash")
|
||||
or f"magnet-{magnet_id}"
|
||||
).strip()
|
||||
if magnet_folder_name:
|
||||
magnet_path_metadata["folder"] = magnet_folder_name
|
||||
|
||||
downloaded = 0
|
||||
for file_idx, node in enumerate(file_entries, 1):
|
||||
@@ -1261,8 +1265,10 @@ class AllDebrid(TableProviderMixin, Provider):
|
||||
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'}")
|
||||
if progress is not None and hasattr(progress, "set_status"):
|
||||
progress.set_status(
|
||||
f"downloading file {file_idx}/{total_files}: {relpath or file_name or 'download'}"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -1282,21 +1288,23 @@ class AllDebrid(TableProviderMixin, Provider):
|
||||
except Exception as exc:
|
||||
debug(f"[alldebrid] unlock_link failed: {exc}, trying locked URL")
|
||||
|
||||
target_path = output_dir
|
||||
rel_path_obj = Path(relpath)
|
||||
if rel_path_obj.parent:
|
||||
target_path = output_dir / rel_path_obj.parent
|
||||
try:
|
||||
target_path.mkdir(parents=True, exist_ok=True)
|
||||
except Exception:
|
||||
target_path = output_dir
|
||||
target_path = adjust_output_dir_for_alldebrid(
|
||||
output_dir,
|
||||
{**magnet_path_metadata, "relpath": relpath},
|
||||
magnet_files,
|
||||
)
|
||||
|
||||
suggested_name = sanitize_filename(rel_path_obj.name) or sanitize_filename(file_name)
|
||||
if not suggested_name:
|
||||
suggested_name = rel_path_obj.name or file_name or f"file-{file_idx}"
|
||||
|
||||
try:
|
||||
result_obj = _download_direct_file(
|
||||
file_url,
|
||||
target_path,
|
||||
quiet=quiet_mode,
|
||||
suggested_filename=rel_path_obj.name,
|
||||
suggested_filename=suggested_name,
|
||||
pipeline_progress=progress,
|
||||
)
|
||||
except Exception as exc:
|
||||
@@ -1315,6 +1323,12 @@ class AllDebrid(TableProviderMixin, Provider):
|
||||
if downloaded == 0:
|
||||
log(f"AllDebrid magnet {magnet_id} produced no downloads", file=sys.stderr)
|
||||
|
||||
try:
|
||||
if progress is not None and hasattr(progress, "clear_status"):
|
||||
progress.clear_status()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return downloaded
|
||||
|
||||
def search(
|
||||
|
||||
Reference in New Issue
Block a user