updating and refining plugin system refactor

This commit is contained in:
2026-04-28 22:20:54 -07:00
parent 8685fbb723
commit 323c24f4f4
33 changed files with 4287 additions and 3312 deletions
+77 -3
View File
@@ -540,7 +540,7 @@ def download_magnet(
def expand_folder_item(
item: Any,
get_search_plugin: Optional[Callable[[str, Dict[str, Any]], Any]],
get_plugin: Optional[Callable[[str, Dict[str, Any]], Any]],
config: Dict[str, Any],
) -> Tuple[List[Any], Optional[str]]:
table = getattr(item, "table", None) if not isinstance(item, dict) else item.get("table")
@@ -564,10 +564,10 @@ def expand_folder_item(
except Exception:
magnet_id = None
if magnet_id is None or get_search_plugin is None:
if magnet_id is None or get_plugin is None:
return [], None
plugin = get_search_plugin("alldebrid", config) if get_search_plugin else None
plugin = get_plugin("alldebrid", config) if get_plugin else None
if plugin is None:
return [], None
@@ -1774,6 +1774,80 @@ class AllDebrid(TableProviderMixin, Provider):
return True
def show_selection_details(
self,
selected_items: List[Any],
*,
ctx: Any,
stage_is_last: bool = True,
source_command: str = "",
table_type: str = "",
table_metadata: Optional[Dict[str, Any]] = None,
**_kwargs: Any,
) -> bool:
_ = table_type
_item, payload, meta = self.resolve_selection_detail_subject(
selected_items,
stage_is_last=stage_is_last,
source_command=source_command,
require_media_kind="file",
)
if not isinstance(payload, dict):
return False
title = str(payload.get("title") or meta.get("name") or "").strip() or "AllDebrid Item"
magnet_name = str(meta.get("magnet_name") or payload.get("detail") or "").strip()
magnet_id = meta.get("magnet_id")
relpath = str(meta.get("relpath") or "").strip()
direct_url = str(payload.get("path") or "").strip()
selection_url = ""
action = meta.get("_selection_action") or meta.get("selection_action")
if isinstance(action, (list, tuple)):
action_tokens = [str(x) for x in action if x is not None]
for idx, token in enumerate(action_tokens):
if str(token).strip().lower() in {"-url", "--url"} and idx + 1 < len(action_tokens):
selection_url = str(action_tokens[idx + 1] or "").strip()
break
try:
from SYS.detail_view_helpers import prepare_detail_metadata, render_selection_detail_view
except Exception:
return super().show_selection_details(
selected_items,
ctx=ctx,
stage_is_last=stage_is_last,
source_command=source_command,
table_type=table_type,
table_metadata=table_metadata,
)
detail_metadata = prepare_detail_metadata(
payload,
title=title,
store=self.name,
path=direct_url or None,
tags=meta.get("tag") or meta.get("tags"),
extra_fields={
"Plugin": self.name,
"Magnet": magnet_name or None,
"Magnet ID": magnet_id,
"Relative Path": relpath or None,
"View": str(meta.get("provider_view") or meta.get("view") or (table_metadata or {}).get("view") or "").strip() or None,
"Direct Url": direct_url or None,
"Selection Url": selection_url or None,
},
)
return render_selection_detail_view(
ctx=ctx,
item=payload,
title=f"AllDebrid Item: {title}",
metadata=detail_metadata,
table_name=self.name,
detail_order=["Title", "Store", "Magnet", "Magnet ID", "Relative Path", "View", "Path", "File", "Folder", "ID", "Direct URL", "Selection URL", "Plugin"],
value_case="preserve",
)
try:
from SYS.result_table_adapters import register_plugin