jj
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:
@@ -815,7 +815,43 @@ class Download_File(Cmdlet):
|
||||
full_metadata=full_metadata if isinstance(full_metadata, dict) else {},
|
||||
)
|
||||
debug(f"[download-file] Downloading provider item via {table}: {sr.title}")
|
||||
downloaded_path = provider.download(sr, final_output_dir)
|
||||
|
||||
# Preserve provider structure when possible (AllDebrid folders -> subfolders).
|
||||
output_dir = final_output_dir
|
||||
try:
|
||||
if str(table).strip().lower() == "alldebrid":
|
||||
from ProviderCore.download import sanitize_filename as _sf
|
||||
|
||||
md = full_metadata if isinstance(full_metadata, dict) else {}
|
||||
magnet_name = None
|
||||
if isinstance(md, dict):
|
||||
magnet_name = md.get("magnet_name") or md.get("folder")
|
||||
if not magnet_name:
|
||||
magnet_name = str(get_field(item, "detail") or "").strip() or None
|
||||
|
||||
if magnet_name:
|
||||
output_dir = Path(output_dir) / _sf(str(magnet_name))
|
||||
|
||||
relpath = None
|
||||
if isinstance(md, dict):
|
||||
relpath = md.get("relpath")
|
||||
if not relpath and isinstance(md.get("file"), dict):
|
||||
relpath = md["file"].get("_relpath")
|
||||
|
||||
if relpath:
|
||||
parts = [p for p in str(relpath).replace("\\", "/").split("/") if p and p not in {".", ".."}]
|
||||
# relpath includes the filename; only join parent directories.
|
||||
for part in parts[:-1]:
|
||||
output_dir = Path(output_dir) / _sf(part)
|
||||
|
||||
try:
|
||||
Path(output_dir).mkdir(parents=True, exist_ok=True)
|
||||
except Exception:
|
||||
output_dir = final_output_dir
|
||||
except Exception:
|
||||
output_dir = final_output_dir
|
||||
|
||||
downloaded_path = provider.download(sr, output_dir)
|
||||
provider_sr = sr
|
||||
|
||||
# OpenLibrary: if provider download failed, do NOT try to download the OpenLibrary page HTML.
|
||||
|
||||
Reference in New Issue
Block a user