update and cleanup repo
This commit is contained in:
+22
-23
@@ -17,7 +17,7 @@ from SYS.result_publication import overlay_existing_result_table, publish_result
|
||||
from SYS.rich_display import show_available_plugins_panel, show_plugin_config_panel
|
||||
from SYS.utils_constant import ALL_SUPPORTED_EXTENSIONS
|
||||
from PluginCore.backend_registry import BackendRegistry
|
||||
from API.HTTP import _download_direct_file
|
||||
from API.HTTP import download_direct_file
|
||||
from .. import _shared as sh
|
||||
|
||||
Cmdlet = sh.Cmdlet
|
||||
@@ -31,7 +31,7 @@ merge_sequences = sh.merge_sequences
|
||||
extract_relationships = sh.extract_relationships
|
||||
extract_duration = sh.extract_duration
|
||||
coerce_to_pipe_object = sh.coerce_to_pipe_object
|
||||
collapse_namespace_tag = sh.collapse_namespace_tag
|
||||
collapse_namespace_tags = sh.collapse_namespace_tags
|
||||
resolve_target_dir = sh.resolve_target_dir
|
||||
resolve_media_kind_by_extension = sh.resolve_media_kind_by_extension
|
||||
coerce_to_path = sh.coerce_to_path
|
||||
@@ -102,10 +102,10 @@ def _maybe_apply_florencevision_tags(
|
||||
config: Dict[str, Any],
|
||||
pipe_obj: Optional[models.PipeObject] = None,
|
||||
) -> List[str]:
|
||||
"""Optionally auto-tag images using the FlorenceVision tool.
|
||||
"""Optionally auto-tag images using the FlorenceVision plugin helper.
|
||||
|
||||
Controlled via config:
|
||||
[tool=florencevision]
|
||||
[plugin=florencevision]
|
||||
enabled=true
|
||||
strict=false
|
||||
|
||||
@@ -114,8 +114,8 @@ def _maybe_apply_florencevision_tags(
|
||||
"""
|
||||
strict = False
|
||||
try:
|
||||
tool_block = (config or {}).get("tool")
|
||||
fv_block = tool_block.get("florencevision") if isinstance(tool_block, dict) else None
|
||||
plugin_block = (config or {}).get("plugin")
|
||||
fv_block = plugin_block.get("florencevision") if isinstance(plugin_block, dict) else None
|
||||
enabled = False
|
||||
if isinstance(fv_block, dict):
|
||||
enabled = bool(fv_block.get("enabled"))
|
||||
@@ -123,7 +123,7 @@ def _maybe_apply_florencevision_tags(
|
||||
if not enabled:
|
||||
return tags
|
||||
|
||||
from tool.florencevision import FlorenceVisionTool
|
||||
from plugins.florencevision import FlorenceVisionTool
|
||||
|
||||
# Special-case: if this file was produced by the `screen-shot` cmdlet,
|
||||
# OCR is more useful than caption/detection for tagging screenshots.
|
||||
@@ -134,12 +134,12 @@ def _maybe_apply_florencevision_tags(
|
||||
if action.lower().startswith("cmdlet:"):
|
||||
cmdlet_name = action.split(":", 1)[1].strip().lower()
|
||||
if cmdlet_name in {"screen-shot", "screen_shot", "screenshot"}:
|
||||
tool_block2 = dict((config or {}).get("tool") or {})
|
||||
fv_block2 = dict(tool_block2.get("florencevision") or {})
|
||||
plugin_block2 = dict((config or {}).get("plugin") or {})
|
||||
fv_block2 = dict(plugin_block2.get("florencevision") or {})
|
||||
fv_block2["task"] = "ocr"
|
||||
tool_block2["florencevision"] = fv_block2
|
||||
plugin_block2["florencevision"] = fv_block2
|
||||
cfg_for_tool = dict(config or {})
|
||||
cfg_for_tool["tool"] = tool_block2
|
||||
cfg_for_tool["plugin"] = plugin_block2
|
||||
except Exception:
|
||||
cfg_for_tool = config
|
||||
|
||||
@@ -1237,7 +1237,7 @@ class Add_File(Cmdlet):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
downloaded = _download_direct_file(
|
||||
downloaded = download_direct_file(
|
||||
url_text,
|
||||
download_root,
|
||||
quiet=False,
|
||||
@@ -1693,9 +1693,8 @@ class Add_File(Cmdlet):
|
||||
) -> Tuple[Optional[Path], Optional[str], Optional[Path]]:
|
||||
plugin_key = None
|
||||
for source in (
|
||||
pipe_obj.provider,
|
||||
pipe_obj.plugin,
|
||||
get_field(result, "plugin"),
|
||||
get_field(result, "provider"),
|
||||
get_field(result, "table"),
|
||||
):
|
||||
candidate = Add_File._normalize_provider_key(source)
|
||||
@@ -1760,7 +1759,7 @@ class Add_File(Cmdlet):
|
||||
str(r_hash),
|
||||
source_url,
|
||||
)
|
||||
downloaded = _download_direct_file(
|
||||
downloaded = download_direct_file(
|
||||
source_url,
|
||||
download_dir,
|
||||
quiet=True,
|
||||
@@ -2028,7 +2027,7 @@ class Add_File(Cmdlet):
|
||||
*,
|
||||
hash_value: str,
|
||||
store: str,
|
||||
provider: Optional[str] = None,
|
||||
plugin: Optional[str] = None,
|
||||
path: Optional[str],
|
||||
tag: List[str],
|
||||
title: Optional[str],
|
||||
@@ -2037,7 +2036,7 @@ class Add_File(Cmdlet):
|
||||
) -> None:
|
||||
pipe_obj.hash = hash_value
|
||||
pipe_obj.store = store
|
||||
pipe_obj.provider = provider
|
||||
pipe_obj.plugin = plugin
|
||||
pipe_obj.is_temp = False
|
||||
pipe_obj.path = path
|
||||
pipe_obj.tag = tag
|
||||
@@ -2260,7 +2259,7 @@ class Add_File(Cmdlet):
|
||||
t for t in tags_from_result
|
||||
if not str(t).strip().lower().startswith("title:")
|
||||
]
|
||||
sidecar_tags = collapse_namespace_tag(
|
||||
sidecar_tags = collapse_namespace_tags(
|
||||
[normalize_title_tag(t) for t in sidecar_tags],
|
||||
"title",
|
||||
prefer="last"
|
||||
@@ -2449,15 +2448,15 @@ class Add_File(Cmdlet):
|
||||
or "unknown"
|
||||
).strip() or "unknown"
|
||||
store_value = str(payload.get("store") or "").strip()
|
||||
provider_value = payload.get("provider")
|
||||
if provider_value is None and plugin_name:
|
||||
provider_value = plugin_name
|
||||
plugin_value = payload.get("plugin")
|
||||
if plugin_value is None and plugin_name:
|
||||
plugin_value = plugin_name
|
||||
|
||||
Add_File._update_pipe_object_destination(
|
||||
pipe_obj,
|
||||
hash_value=hash_value,
|
||||
store=store_value,
|
||||
provider=str(provider_value) if provider_value else None,
|
||||
plugin=str(plugin_value) if plugin_value else None,
|
||||
path=path_value,
|
||||
tag=tag_values,
|
||||
title=title_value,
|
||||
@@ -2584,7 +2583,7 @@ class Add_File(Cmdlet):
|
||||
pipe_obj,
|
||||
hash_value=f_hash or "unknown",
|
||||
store="",
|
||||
provider=plugin_name or None,
|
||||
plugin=plugin_name or None,
|
||||
path=file_path,
|
||||
tag=pipe_obj.tag,
|
||||
title=pipe_obj.title or (media_path.name if media_path else None),
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
"""Compatibility wrapper for moved metadata note add cmdlet."""
|
||||
|
||||
from cmdlet.metadata.note_add import * # noqa: F401,F403
|
||||
@@ -1,9 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
"""Compatibility wrapper for moved metadata relationship add cmdlet."""
|
||||
|
||||
from cmdlet.metadata import relationship_add as _relationship_add
|
||||
from cmdlet.metadata.relationship_add import * # noqa: F401,F403
|
||||
|
||||
# Preserve direct private helper imports used by tests and legacy callers.
|
||||
_extract_hash_and_store = _relationship_add._extract_hash_and_store
|
||||
@@ -1,5 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
"""Compatibility wrapper for moved metadata URL add cmdlet."""
|
||||
|
||||
from cmdlet.metadata.url_add import * # noqa: F401,F403
|
||||
@@ -49,9 +49,9 @@ def _extract_hash_from_hydrus_file_url(url: str) -> str:
|
||||
def _hydrus_instance_names(config: Dict[str, Any]) -> Set[str]:
|
||||
instances: Set[str] = set()
|
||||
try:
|
||||
store_cfg = config.get("store") if isinstance(config, dict) else None
|
||||
if isinstance(store_cfg, dict):
|
||||
hydrus_cfg = store_cfg.get("hydrusnetwork")
|
||||
plugin_cfg = config.get("plugin") if isinstance(config, dict) else None
|
||||
if isinstance(plugin_cfg, dict):
|
||||
hydrus_cfg = plugin_cfg.get("hydrusnetwork")
|
||||
if isinstance(hydrus_cfg, dict):
|
||||
instances = {
|
||||
str(k).strip().lower()
|
||||
|
||||
@@ -133,13 +133,13 @@ class Delete_File(sh.Cmdlet):
|
||||
provider_name = None
|
||||
full_metadata: Dict[str, Any] = {}
|
||||
if isinstance(item, dict):
|
||||
provider_name = item.get("provider") or item.get("table")
|
||||
provider_name = item.get("plugin") or item.get("table")
|
||||
raw_meta = item.get("full_metadata") or item.get("metadata")
|
||||
if isinstance(raw_meta, dict):
|
||||
full_metadata = raw_meta
|
||||
else:
|
||||
try:
|
||||
provider_name = sh.get_field(item, "provider") or sh.get_field(item, "table")
|
||||
provider_name = sh.get_field(item, "plugin") or sh.get_field(item, "table")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
@@ -542,4 +542,4 @@ class Delete_File(sh.Cmdlet):
|
||||
|
||||
|
||||
# Instantiate and register the cmdlet
|
||||
Delete_File()
|
||||
CMDLET = Delete_File()
|
||||
|
||||
+9
-10
@@ -19,7 +19,7 @@ import shutil
|
||||
import webbrowser
|
||||
|
||||
|
||||
from API.HTTP import _download_direct_file
|
||||
from API.HTTP import download_direct_file
|
||||
from SYS.models import DownloadError, DownloadOptions, DownloadMediaResult
|
||||
from SYS.logger import log, debug_panel, is_debug_enabled
|
||||
from SYS.payload_builders import build_file_result_payload, build_table_result_payload
|
||||
@@ -235,7 +235,7 @@ class Download_File(Cmdlet):
|
||||
|
||||
action = str(
|
||||
result.get("action")
|
||||
or result.get("provider_action")
|
||||
or result.get("plugin_action")
|
||||
or ""
|
||||
).strip().lower()
|
||||
|
||||
@@ -338,12 +338,12 @@ class Download_File(Cmdlet):
|
||||
path_value: Optional[Any] = path
|
||||
|
||||
if isinstance(path, dict):
|
||||
provider_action = str(
|
||||
plugin_action = str(
|
||||
path.get("action")
|
||||
or path.get("provider_action")
|
||||
or path.get("plugin_action")
|
||||
or ""
|
||||
).strip().lower()
|
||||
if provider_action == "download_items" or bool(path.get("download_items")):
|
||||
if plugin_action == "download_items" or bool(path.get("download_items")):
|
||||
request_metadata = path.get("metadata") or path.get("full_metadata") or {}
|
||||
if not isinstance(request_metadata, dict):
|
||||
request_metadata = {}
|
||||
@@ -522,7 +522,7 @@ class Download_File(Cmdlet):
|
||||
|
||||
# Direct Download Fallback
|
||||
attempted_download = True
|
||||
result_obj = _download_direct_file(
|
||||
result_obj = download_direct_file(
|
||||
str(url),
|
||||
final_output_dir,
|
||||
quiet=quiet_mode,
|
||||
@@ -569,7 +569,7 @@ class Download_File(Cmdlet):
|
||||
key = self._normalize_provider_key(table_hint)
|
||||
if key:
|
||||
return key
|
||||
provider_hint = get_field(item, "provider")
|
||||
provider_hint = get_field(item, "plugin")
|
||||
key = self._normalize_provider_key(provider_hint)
|
||||
if key:
|
||||
return key
|
||||
@@ -743,7 +743,7 @@ class Download_File(Cmdlet):
|
||||
and isinstance(target, str) and target.startswith("http")):
|
||||
|
||||
suggested_name = str(title).strip() if title is not None else None
|
||||
result_obj = _download_direct_file(
|
||||
result_obj = download_direct_file(
|
||||
target,
|
||||
final_output_dir,
|
||||
quiet=quiet_mode,
|
||||
@@ -926,7 +926,6 @@ class Download_File(Cmdlet):
|
||||
}
|
||||
if provider_hint:
|
||||
payload["plugin"] = str(provider_hint)
|
||||
payload["provider"] = str(provider_hint)
|
||||
if full_metadata:
|
||||
payload["metadata"] = full_metadata
|
||||
if notes:
|
||||
@@ -1125,7 +1124,7 @@ class Download_File(Cmdlet):
|
||||
filename += ext_text
|
||||
|
||||
if download_url:
|
||||
result_obj = _download_direct_file(
|
||||
result_obj = download_direct_file(
|
||||
download_url,
|
||||
final_output_dir,
|
||||
quiet=True,
|
||||
|
||||
+16
-16
@@ -43,7 +43,7 @@ from SYS import pipeline as pipeline_context
|
||||
# Playwright & Screenshot Dependencies
|
||||
# ============================================================================
|
||||
|
||||
from tool.playwright import PlaywrightTimeoutError, PlaywrightTool
|
||||
from plugins.playwright import PlaywrightTimeoutError, PlaywrightTool
|
||||
|
||||
try:
|
||||
from SYS.config import resolve_output_dir
|
||||
@@ -1525,22 +1525,22 @@ def _capture(
|
||||
{}) or {})
|
||||
except Exception:
|
||||
base_cfg = {}
|
||||
tool_block = dict(base_cfg.get("tool") or {}
|
||||
plugin_block = dict(base_cfg.get("plugin") or {}
|
||||
) if isinstance(base_cfg,
|
||||
dict) else {}
|
||||
pw_block = (
|
||||
dict(tool_block.get("playwright") or {})
|
||||
if isinstance(tool_block,
|
||||
dict(plugin_block.get("playwright") or {})
|
||||
if isinstance(plugin_block,
|
||||
dict) else {}
|
||||
)
|
||||
pw_block["browser"] = "chromium"
|
||||
tool_block["playwright"] = pw_block
|
||||
plugin_block["playwright"] = pw_block
|
||||
if isinstance(base_cfg, dict):
|
||||
base_cfg["tool"] = tool_block
|
||||
base_cfg["plugin"] = plugin_block
|
||||
tool = PlaywrightTool(base_cfg)
|
||||
except Exception:
|
||||
tool = PlaywrightTool({
|
||||
"tool": {
|
||||
"plugin": {
|
||||
"playwright": {
|
||||
"browser": "chromium"
|
||||
}
|
||||
@@ -1888,8 +1888,8 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
quality_value: Optional[int] = None
|
||||
if not format_value:
|
||||
try:
|
||||
tool_cfg = config.get("tool", {}) if isinstance(config, dict) else {}
|
||||
pw_cfg = tool_cfg.get("playwright") if isinstance(tool_cfg, dict) else None
|
||||
plugin_cfg = config.get("plugin", {}) if isinstance(config, dict) else {}
|
||||
pw_cfg = plugin_cfg.get("playwright") if isinstance(plugin_cfg, dict) else None
|
||||
if isinstance(pw_cfg, dict):
|
||||
format_value = pw_cfg.get("format")
|
||||
except Exception:
|
||||
@@ -1901,8 +1901,8 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
quality_value = _normalize_quality(raw_quality_value)
|
||||
else:
|
||||
try:
|
||||
tool_cfg = config.get("tool", {}) if isinstance(config, dict) else {}
|
||||
pw_cfg = tool_cfg.get("playwright") if isinstance(tool_cfg, dict) else None
|
||||
plugin_cfg = config.get("plugin", {}) if isinstance(config, dict) else {}
|
||||
pw_cfg = plugin_cfg.get("playwright") if isinstance(plugin_cfg, dict) else None
|
||||
if isinstance(pw_cfg, dict) and pw_cfg.get("screenshot_quality") not in (None, ""):
|
||||
quality_value = _normalize_quality(pw_cfg.get("screenshot_quality"))
|
||||
except Exception:
|
||||
@@ -1994,18 +1994,18 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
shared_playwright_tool: Optional[PlaywrightTool] = None
|
||||
try:
|
||||
if isinstance(config, dict):
|
||||
tool_block = dict(config.get("tool") or {})
|
||||
pw_block = dict(tool_block.get("playwright") or {})
|
||||
plugin_block = dict(config.get("plugin") or {})
|
||||
pw_block = dict(plugin_block.get("playwright") or {})
|
||||
pw_block["browser"] = "chromium"
|
||||
pw_block["user_agent"] = "native"
|
||||
pw_block["viewport_width"] = int(DEFAULT_VIEWPORT.get("width", 1920))
|
||||
pw_block["viewport_height"] = int(DEFAULT_VIEWPORT.get("height", 1080))
|
||||
tool_block["playwright"] = pw_block
|
||||
plugin_block["playwright"] = pw_block
|
||||
pw_local_cfg = dict(config)
|
||||
pw_local_cfg["tool"] = tool_block
|
||||
pw_local_cfg["plugin"] = plugin_block
|
||||
else:
|
||||
pw_local_cfg = {
|
||||
"tool": {
|
||||
"plugin": {
|
||||
"playwright": {
|
||||
"browser": "chromium",
|
||||
"user_agent": "native",
|
||||
|
||||
@@ -164,7 +164,7 @@ def _summarize_worker_results(results: Sequence[Dict[str, Any]], preview_limit:
|
||||
|
||||
|
||||
class search_file(Cmdlet):
|
||||
"""Class-based search-file cmdlet for searching backends and providers."""
|
||||
"""Class-based search-file cmdlet for searching backends and plugins."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__(
|
||||
@@ -187,9 +187,9 @@ class search_file(Cmdlet):
|
||||
),
|
||||
],
|
||||
detail=[
|
||||
"Search across configured store backends or plugin providers.",
|
||||
"Search across configured storage backends or plugins.",
|
||||
"Use -instance to target a specific configured backend/instance by name.",
|
||||
"Use -plugin with -instance to target a named provider config.",
|
||||
"Use -plugin with -instance to target a named plugin config.",
|
||||
"URL search: url:* (any URL) or url:<value> (URL substring)",
|
||||
"Extension search: ext:<value> (e.g., ext:png)",
|
||||
"Hydrus-style extension: system:filetype = png",
|
||||
@@ -1216,7 +1216,7 @@ class search_file(Cmdlet):
|
||||
try:
|
||||
table.set_table_metadata(
|
||||
{
|
||||
"provider": "web",
|
||||
"plugin": "web",
|
||||
"site": site_host,
|
||||
"query": search_query,
|
||||
"filetype": requested_type,
|
||||
@@ -1490,7 +1490,7 @@ class search_file(Cmdlet):
|
||||
|
||||
return 1
|
||||
|
||||
# Align with provider default when user did not set -limit.
|
||||
# Align with plugin default when user did not set -limit.
|
||||
if not limit_set:
|
||||
limit = 50
|
||||
|
||||
@@ -1632,7 +1632,7 @@ 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
|
||||
# Ensure plugin source is present so downstream cmdlets can resolve the owner.
|
||||
if "source" not in item_dict:
|
||||
item_dict["source"] = plugin_name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user