dfdf
This commit is contained in:
@@ -523,7 +523,7 @@ local function _refresh_store_cache(timeout_seconds)
|
||||
if not resp or not resp.success or type(resp.choices) ~= 'table' then
|
||||
_lua_log('stores: failed to load store choices via helper; stderr=' .. tostring(resp and resp.stderr or '') .. ' error=' .. tostring(resp and resp.error or ''))
|
||||
|
||||
-- Fallback: directly call Python to import CLI.get_store_choices().
|
||||
-- Fallback: directly call Python to import MedeiaCLI.get_store_choices().
|
||||
-- This avoids helper IPC issues and still stays in sync with the REPL.
|
||||
local python = (opts and opts.python_path) and tostring(opts.python_path) or 'python'
|
||||
local cli_path = (opts and opts.cli_path) and tostring(opts.cli_path) or nil
|
||||
@@ -537,7 +537,7 @@ local function _refresh_store_cache(timeout_seconds)
|
||||
if cli_path and cli_path ~= '' then
|
||||
local root = tostring(cli_path):match('(.*)[/\\]') or ''
|
||||
if root ~= '' then
|
||||
local code = "import json, sys; sys.path.insert(0, r'" .. root .. "'); from CLI import get_store_choices; print(json.dumps(get_store_choices()))"
|
||||
local code = "import json, sys; sys.path.insert(0, r'" .. root .. "'); from CLI import MedeiaCLI; print(json.dumps(MedeiaCLI.get_store_choices()))"
|
||||
local res = utils.subprocess({
|
||||
args = { python, '-c', code },
|
||||
cancellable = false,
|
||||
@@ -1027,7 +1027,7 @@ local function _start_download_flow_for_current()
|
||||
return
|
||||
end
|
||||
ensure_mpv_ipc_server()
|
||||
M.run_pipeline('get-file -store ' .. quote_pipeline_arg(store_hash.store) .. ' -hash ' .. store_hash.hash .. ' -path ' .. quote_pipeline_arg(folder))
|
||||
M.run_pipeline('get-file -store ' .. quote_pipeline_arg(store_hash.store) .. ' -query ' .. quote_pipeline_arg('hash:' .. store_hash.hash) .. ' -path ' .. quote_pipeline_arg(folder))
|
||||
mp.osd_message('Download started', 2)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -136,33 +136,10 @@ def _run_op(op: str, data: Any) -> Dict[str, Any]:
|
||||
|
||||
# Provide store backend choices using the same source as CLI/Typer autocomplete.
|
||||
if op_name in {"store-choices", "store_choices", "get-store-choices", "get_store_choices"}:
|
||||
# Preferred: call the same choice function used by the CLI completer.
|
||||
try:
|
||||
from CLI import get_store_choices # noqa: WPS433
|
||||
from CLI import MedeiaCLI # noqa: WPS433
|
||||
|
||||
backends = get_store_choices()
|
||||
choices = sorted({str(n) for n in (backends or []) if str(n).strip()})
|
||||
except Exception:
|
||||
# Fallback: direct Store registry enumeration using loaded config.
|
||||
try:
|
||||
cfg = load_config() or {}
|
||||
except Exception:
|
||||
cfg = {}
|
||||
try:
|
||||
from Store import Store # noqa: WPS433
|
||||
|
||||
storage = Store(cfg, suppress_debug=True)
|
||||
backends = storage.list_backends() or []
|
||||
choices = sorted({str(n) for n in backends if str(n).strip()})
|
||||
except Exception as exc:
|
||||
return {
|
||||
"success": False,
|
||||
"stdout": "",
|
||||
"stderr": "",
|
||||
"error": f"{type(exc).__name__}: {exc}",
|
||||
"table": None,
|
||||
"choices": [],
|
||||
}
|
||||
backends = MedeiaCLI.get_store_choices()
|
||||
choices = sorted({str(n) for n in (backends or []) if str(n).strip()})
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
|
||||
Reference in New Issue
Block a user