diff --git a/MPV/LUA/main.lua b/MPV/LUA/main.lua index 60942b4..6070cd4 100644 --- a/MPV/LUA/main.lua +++ b/MPV/LUA/main.lua @@ -2751,57 +2751,66 @@ mp.register_script_message('medios-start-helper', function() end) mp.register_script_message('medios-load-url-event', function(json) - _lua_log('Load URL event handler called with: ' .. tostring(json or '')) + _lua_log('[LOAD-URL] Event handler called with: ' .. tostring(json or 'nil')) local ok, event = pcall(utils.parse_json, json) if not ok or type(event) ~= 'table' then - _lua_log('Load URL: failed to parse JSON: ' .. tostring(json)) + _lua_log('[LOAD-URL] Failed to parse JSON: ' .. tostring(json)) mp.osd_message('Failed to parse URL', 2) if ensure_uosc_loaded() then + _lua_log('[LOAD-URL] Closing menu due to parse error') mp.commandv('script-message-to', 'uosc', 'close-menu', LOAD_URL_MENU_TYPE) end return end + _lua_log('[LOAD-URL] Parsed event: type=' .. tostring(event.type) .. ', query=' .. tostring(event.query)) if event.type ~= 'search' then - _lua_log('Load URL: event type is ' .. tostring(event.type) .. ', expected search') + _lua_log('[LOAD-URL] Event type is not search: ' .. tostring(event.type)) if ensure_uosc_loaded() then + _lua_log('[LOAD-URL] Closing menu due to type mismatch') mp.commandv('script-message-to', 'uosc', 'close-menu', LOAD_URL_MENU_TYPE) end return end local url = trim(tostring(event.query or '')) + _lua_log('[LOAD-URL] Trimmed URL: "' .. url .. '"') if url == '' then + _lua_log('[LOAD-URL] URL is empty') mp.osd_message('URL is empty', 2) if ensure_uosc_loaded() then + _lua_log('[LOAD-URL] Closing menu due to empty URL') mp.commandv('script-message-to', 'uosc', 'close-menu', LOAD_URL_MENU_TYPE) end return end mp.osd_message('Loading URL...', 1) - _lua_log('Load URL: ' .. url) + _lua_log('[LOAD-URL] Starting to load: ' .. url) local function close_menu() - _lua_log('Load URL: closing menu') + _lua_log('[LOAD-URL] Closing menu') if ensure_uosc_loaded() then + _lua_log('[LOAD-URL] Sending close-menu command to UOSC') mp.commandv('script-message-to', 'uosc', 'close-menu', LOAD_URL_MENU_TYPE) + else + _lua_log('[LOAD-URL] UOSC not loaded, cannot close menu') end end -- First, always try direct loadfile. This is the fastest path. local can_direct = _url_can_direct_load(url) - _lua_log('Load URL: can_direct_load=' .. tostring(can_direct)) + _lua_log('[LOAD-URL] Checking if URL can be loaded directly: ' .. tostring(can_direct)) if can_direct then - _lua_log('Load URL: attempting direct loadfile') + _lua_log('[LOAD-URL] Attempting direct loadfile') local ok_load = pcall(mp.commandv, 'loadfile', url, 'replace') if ok_load then - _lua_log('Load URL: direct loadfile succeeded') + _lua_log('[LOAD-URL] Direct loadfile command sent successfully') mp.osd_message('URL loaded', 2) close_menu() return else - _lua_log('Load URL: direct loadfile failed') + _lua_log('[LOAD-URL] Direct loadfile command failed') mp.osd_message('Load URL failed (direct)', 3) close_menu() return @@ -2809,29 +2818,30 @@ mp.register_script_message('medios-load-url-event', function(json) end -- Complex streams (YouTube, DASH, etc.) need the pipeline helper. - _lua_log('Load URL: URL needs pipeline helper') + _lua_log('[LOAD-URL] URL requires pipeline helper for processing') ensure_mpv_ipc_server() local helper_ready = ensure_pipeline_helper_running() - _lua_log('Load URL: helper_ready=' .. tostring(helper_ready)) + _lua_log('[LOAD-URL] Pipeline helper ready: ' .. tostring(helper_ready)) if not helper_ready then - mp.osd_message('Pipeline helper not running (try right-click menu)', 3) + _lua_log('[LOAD-URL] Pipeline helper not available') + mp.osd_message('Pipeline helper not running (try menu again)', 3) close_menu() return end -- Use pipeline to download/prepare the URL local pipeline_cmd = '.mpv -url ' .. quote_pipeline_arg(url) .. ' -play' - _lua_log('Load URL: executing pipeline command: ' .. pipeline_cmd) + _lua_log('[LOAD-URL] Sending to pipeline: ' .. pipeline_cmd) M.run_pipeline(pipeline_cmd, nil, function(resp, err) - _lua_log('Load URL: pipeline callback fired. resp=' .. tostring(resp) .. ', err=' .. tostring(err)) + _lua_log('[LOAD-URL] Pipeline callback received: resp=' .. tostring(resp) .. ', err=' .. tostring(err)) if err then - _lua_log('Load URL: pipeline error: ' .. tostring(err)) + _lua_log('[LOAD-URL] Pipeline error: ' .. tostring(err)) mp.osd_message('Load URL failed: ' .. tostring(err), 3) close_menu() return end - _lua_log('Load URL: URL loaded successfully via pipeline') + _lua_log('[LOAD-URL] URL loaded successfully') mp.osd_message('URL loaded', 2) close_menu() end)