diff --git a/API/data/alldebrid.json b/API/data/alldebrid.json index 66708bf..95e5710 100644 --- a/API/data/alldebrid.json +++ b/API/data/alldebrid.json @@ -494,7 +494,7 @@ "mediafire\\.com/(\\?|download/|file/|download\\.php\\?)([0-9a-z]{15})" ], "regexp": "mediafire\\.com/(\\?|download/|file/|download\\.php\\?)([0-9a-z]{15})", - "status": false + "status": true }, "mixdrop": { "name": "mixdrop", diff --git a/MPV/LUA/main.lua b/MPV/LUA/main.lua index faebe5b..a8bb333 100644 --- a/MPV/LUA/main.lua +++ b/MPV/LUA/main.lua @@ -4,7 +4,7 @@ local msg = require 'mp.msg' local M = {} -local MEDEIA_LUA_VERSION = '2026-03-21.3' +local MEDEIA_LUA_VERSION = '2026-03-21.4' -- Expose a tiny breadcrumb for debugging which script version is loaded. pcall(mp.set_property, 'user-data/medeia-lua-version', MEDEIA_LUA_VERSION) @@ -880,7 +880,7 @@ local function _is_pipeline_helper_ready() helper_version = mp.get_property_native('user-data/medeia-pipeline-helper-version') end helper_version = tostring(helper_version or '') - if helper_version ~= '2026-03-22.4' then + if helper_version ~= '2026-03-22.5' then return false end @@ -947,7 +947,7 @@ local function _helper_ready_diagnostics() end return 'ready=' .. tostring(ready or '') .. ' helper_version=' .. tostring(helper_version or '') - .. ' required_version=2026-03-22.4' + .. ' required_version=2026-03-22.5' .. ' last_value=' .. tostring(_helper_ready_last_value or '') .. ' last_seen_age=' .. tostring(age) end diff --git a/MPV/pipeline_helper.py b/MPV/pipeline_helper.py index ed24d46..159f6ea 100644 --- a/MPV/pipeline_helper.py +++ b/MPV/pipeline_helper.py @@ -20,7 +20,7 @@ This helper is intentionally minimal: one request at a time, last-write-wins. from __future__ import annotations -MEDEIA_MPV_HELPER_VERSION = "2026-03-22.4" +MEDEIA_MPV_HELPER_VERSION = "2026-03-22.5" import argparse import json @@ -1322,36 +1322,72 @@ def main(argv: Optional[list[str]] = None) -> int: # path used by this helper (which comes from the running MPV instance). os.environ["MEDEIA_MPV_IPC"] = str(args.ipc) - if platform.system() == "Windows": - try: - sibling_pids = [ - pid - for pid in _windows_list_pipeline_helper_pids(str(args.ipc)) - if pid and pid != os.getpid() - ] - if sibling_pids: - _append_helper_log( - f"[helper] terminating older helper pids for ipc={args.ipc}: {','.join(str(pid) for pid in sibling_pids)}" - ) - _windows_kill_pids(sibling_pids) - time.sleep(0.25) - except Exception as exc: - _append_helper_log( - f"[helper] failed to terminate older helpers: {type(exc).__name__}: {exc}" - ) + lock_wait_deadline = time.time() + min(max(1.5, float(args.timeout or 0.0)), 8.0) + lock_wait_logged = False + last_killed_pid_signature = "" + _lock_fh = None - # Ensure single helper instance per ipc. - _lock_fh = _acquire_ipc_lock(str(args.ipc)) - if _lock_fh is None: - _append_helper_log( - f"[helper] another instance already holds lock for ipc={args.ipc}; exiting" - ) - return 0 + while _lock_fh is None: + if platform.system() == "Windows": + try: + sibling_pids = [ + pid + for pid in _windows_list_pipeline_helper_pids(str(args.ipc)) + if pid and pid != os.getpid() + ] + if sibling_pids: + signature = ",".join(str(pid) for pid in sibling_pids) + if signature != last_killed_pid_signature: + _append_helper_log( + f"[helper] terminating older helper pids for ipc={args.ipc}: {signature}" + ) + last_killed_pid_signature = signature + _windows_kill_pids(sibling_pids) + time.sleep(0.35) + except Exception as exc: + _append_helper_log( + f"[helper] failed to terminate older helpers: {type(exc).__name__}: {exc}" + ) + + _lock_fh = _acquire_ipc_lock(str(args.ipc)) + if _lock_fh is not None: + break + + if not lock_wait_logged: + _append_helper_log( + f"[helper] waiting for helper lock release ipc={args.ipc}" + ) + lock_wait_logged = True + + if time.time() >= lock_wait_deadline: + _append_helper_log( + f"[helper] another instance still holds lock for ipc={args.ipc}; exiting after wait" + ) + return 0 + + time.sleep(0.20) try: _append_helper_log( f"[helper] version={MEDEIA_MPV_HELPER_VERSION} started ipc={args.ipc}" ) + try: + _lock_fh.seek(0) + _lock_fh.truncate() + _lock_fh.write( + json.dumps( + { + "pid": os.getpid(), + "version": MEDEIA_MPV_HELPER_VERSION, + "ipc": str(args.ipc), + "started_at": int(time.time()), + }, + ensure_ascii=False, + ) + ) + _lock_fh.flush() + except Exception: + pass try: _append_helper_log( f"[helper] file={Path(__file__).resolve()} cwd={Path.cwd().resolve()}"