This commit is contained in:
2026-01-31 23:22:30 -08:00
parent ed44d69ef1
commit 753cdfb196
6 changed files with 454 additions and 35 deletions

View File

@@ -1229,10 +1229,63 @@ class Add_File(Cmdlet):
hash_hint = get_field(result, "hash") or get_field(result, "file_hash") or getattr(pipe_obj, "hash", None)
return candidate, hash_hint, None
downloaded_path, hash_hint, tmp_dir = Add_File._maybe_download_alldebrid_result(
result,
pipe_obj,
config,
)
if downloaded_path:
pipe_obj.path = str(downloaded_path)
return downloaded_path, hash_hint, tmp_dir
debug(f"No resolution path matched. result type={type(result).__name__}")
log("File path could not be resolved")
return None, None, None
@staticmethod
def _normalize_provider_key(value: Optional[Any]) -> Optional[str]:
if value is None:
return None
try:
normalized = str(value).strip().lower()
except Exception:
return None
if not normalized:
return None
if "." in normalized:
normalized = normalized.split(".", 1)[0]
return normalized
@staticmethod
def _maybe_download_alldebrid_result(
result: Any,
pipe_obj: models.PipeObject,
config: Dict[str, Any],
) -> Tuple[Optional[Path], Optional[str], Optional[Path]]:
provider_key = None
for source in (
pipe_obj.provider,
get_field(result, "provider"),
get_field(result, "table"),
):
candidate = Add_File._normalize_provider_key(source)
if candidate:
provider_key = candidate
break
if provider_key != "alldebrid":
return None, None, None
try:
from Provider.alldebrid import AllDebrid
except Exception:
return None, None, None
try:
return AllDebrid.download_for_pipe_result(result, pipe_obj, config)
except Exception as exc:
debug(f"[add-file] AllDebrid download helper failed: {exc}")
return None, None, None
@staticmethod
def _download_provider_source(
pipe_obj: models.PipeObject,