This commit is contained in:
2026-01-03 03:37:48 -08:00
parent 6e9a0c28ff
commit 73f3005393
23 changed files with 1791 additions and 442 deletions

View File

@@ -297,6 +297,10 @@ end
local _cached_store_names = {}
local _store_cache_loaded = false
-- Optional index into _cached_store_names (used by some older menu code paths).
-- If unset, callers should fall back to reading SELECTED_STORE_PROP.
local _selected_store_index = nil
local SELECTED_STORE_PROP = 'user-data/medeia-selected-store'
local STORE_PICKER_MENU_TYPE = 'medeia_store_picker'
local _selected_store_loaded = false
@@ -438,7 +442,7 @@ local function get_mpv_ipc_path()
end
local function ensure_mpv_ipc_server()
-- `.pipe -play` (Python) controls MPV via JSON IPC. If mpv was started
-- `.mpv -play` (Python) controls MPV via JSON IPC. If mpv was started
-- without --input-ipc-server, make sure we set one so the running instance
-- can be controlled (instead of Python spawning a separate mpv).
local ipc = mp.get_property('input-ipc-server')
@@ -2192,6 +2196,37 @@ local function _call_mpv_api(request)
end
end
-- Run a Medeia pipeline command via the Python pipeline helper (IPC request/response).
-- Returns stdout string on success, or nil on failure.
function M.run_pipeline(pipeline_cmd, seeds)
pipeline_cmd = trim(tostring(pipeline_cmd or ''))
if pipeline_cmd == '' then
return nil
end
ensure_mpv_ipc_server()
local resp = run_pipeline_via_ipc_response(pipeline_cmd, seeds, 30)
if type(resp) == 'table' and resp.success then
return resp.stdout or ''
end
local err = ''
if type(resp) == 'table' then
if resp.error and tostring(resp.error) ~= '' then
err = tostring(resp.error)
elseif resp.stderr and tostring(resp.stderr) ~= '' then
err = tostring(resp.stderr)
end
end
if err ~= '' then
_lua_log('pipeline failed cmd=' .. tostring(pipeline_cmd) .. ' err=' .. err)
else
_lua_log('pipeline failed cmd=' .. tostring(pipeline_cmd) .. ' err=<unknown>')
end
return nil
end
-- Helper to run pipeline and parse JSON output
function M.run_pipeline_json(pipeline_cmd, seeds)
-- Append | output-json if not present
@@ -2584,7 +2619,7 @@ mp.register_script_message('medios-load-url-event', function(json)
end
ensure_mpv_ipc_server()
local out = M.run_pipeline('.pipe -url ' .. quote_pipeline_arg(url) .. ' -play')
local out = M.run_pipeline('.mpv -url ' .. quote_pipeline_arg(url) .. ' -play')
if out ~= nil then
if ensure_uosc_loaded() then
mp.commandv('script-message-to', 'uosc', 'close-menu', LOAD_URL_MENU_TYPE)