refactor(download): remove ProviderCore/download.py, move sanitize_filename to SYS.utils, replace callers to use API.HTTP.HTTPClient

This commit is contained in:
2026-01-06 01:38:59 -08:00
parent 3b363dd536
commit 41c11d39fd
38 changed files with 2640 additions and 526 deletions

View File

@@ -241,6 +241,16 @@ class search_file(Cmdlet):
else:
provider_label = provider_text[:1].upper() + provider_text[1:] if provider_text else "Provider"
normalized_query = str(query or "").strip()
provider_filters: Dict[str, Any] = {}
try:
normalized_query, provider_filters = provider.extract_query_arguments(query)
except Exception:
provider_filters = {}
normalized_query = (normalized_query or "").strip()
query = normalized_query or "*"
provider_filters = dict(provider_filters or {})
if provider_lower == "alldebrid" and effective_open_id is not None:
table_title = f"{provider_label} Files: {effective_open_id}".strip().rstrip(":")
else:
@@ -267,17 +277,22 @@ class search_file(Cmdlet):
table.set_table_metadata(table_meta)
except Exception:
pass
table.set_source_command("search-file", list(args_list))
debug(f"[search-file] Calling {provider_name}.search()")
if provider_lower == "alldebrid":
filters = {"view": "folders"}
search_open_id = parsed_open_id if parsed_open_id is not None else open_id
if search_open_id is not None:
filters = {"view": "files", "magnet_id": search_open_id}
results = provider.search(query, limit=limit, filters=filters)
if provider_lower == "vimm":
# Keep auto-staged download-file from inheriting raw query tokens;
# only propagate provider hint so @N expands to a clean downloader call.
table.set_source_command("search-file", ["-provider", provider_name])
else:
results = provider.search(query, limit=limit)
table.set_source_command("search-file", list(args_list))
search_filters = dict(provider_filters)
debug(f"[search-file] Calling {provider_name}.search(filters={search_filters})")
if provider_lower == "alldebrid":
search_open_id = parsed_open_id if parsed_open_id is not None else open_id
view_value = "files" if search_open_id is not None else "folders"
search_filters["view"] = view_value
if search_open_id is not None:
search_filters["magnet_id"] = search_open_id
results = provider.search(query, limit=limit, filters=search_filters or None)
debug(f"[search-file] {provider_name} -> {len(results or [])} result(s)")
# HIFI artist UX: if there is exactly one artist match, auto-expand
@@ -342,6 +357,10 @@ class search_file(Cmdlet):
if "table" not in item_dict:
item_dict["table"] = table_type
# Ensure provider source is present so downstream cmdlets (select) can resolve provider
if "source" not in item_dict:
item_dict["source"] = provider_name
row_index = len(table.rows)
table.add_result(search_result)