updated installer script
This commit is contained in:
@@ -804,6 +804,7 @@ local _store_status_hint_for_url
|
||||
local _refresh_current_store_url_status
|
||||
local _skip_next_store_check_url = ''
|
||||
local _pick_folder_windows
|
||||
M._ytdl_download_format_fallbacks = M._ytdl_download_format_fallbacks or {}
|
||||
|
||||
function M._load_store_choices_direct_async(cb)
|
||||
cb = cb or function() end
|
||||
@@ -2070,6 +2071,10 @@ function M._prepare_ytdl_format_for_web_load(url, reason)
|
||||
return false
|
||||
end
|
||||
|
||||
if explicit_reload_url ~= '' and first_value and first_value ~= '' then
|
||||
M._ytdl_download_format_fallbacks[explicit_reload_url] = first_value
|
||||
end
|
||||
|
||||
pcall(mp.set_property, 'options/ytdl-format', '')
|
||||
pcall(mp.set_property, 'file-local-options/ytdl-format', '')
|
||||
pcall(mp.set_property, 'ytdl-format', '')
|
||||
@@ -2078,6 +2083,7 @@ function M._prepare_ytdl_format_for_web_load(url, reason)
|
||||
.. ' reason=' .. tostring(reason or 'on-load')
|
||||
.. ' url=' .. tostring(url)
|
||||
.. ' values=' .. table.concat(active_props, '; ')
|
||||
.. ' fallback_cached=' .. tostring(first_value and first_value ~= '' and 'yes' or 'no')
|
||||
)
|
||||
return true
|
||||
end
|
||||
@@ -2119,6 +2125,28 @@ local function _normalize_url_for_store_lookup(url)
|
||||
return url:lower()
|
||||
end
|
||||
|
||||
function M._remember_ytdl_download_format(url, fmt)
|
||||
local normalized = _normalize_url_for_store_lookup(url)
|
||||
local value = trim(tostring(fmt or ''))
|
||||
if normalized == '' or value == '' then
|
||||
return false
|
||||
end
|
||||
M._ytdl_download_format_fallbacks[normalized] = value
|
||||
return true
|
||||
end
|
||||
|
||||
function M._get_remembered_ytdl_download_format(url)
|
||||
local normalized = _normalize_url_for_store_lookup(url)
|
||||
if normalized == '' then
|
||||
return nil
|
||||
end
|
||||
local cached = trim(tostring((M._ytdl_download_format_fallbacks or {})[normalized] or ''))
|
||||
if cached == '' then
|
||||
return nil
|
||||
end
|
||||
return cached
|
||||
end
|
||||
|
||||
local function _build_store_lookup_needles(url)
|
||||
local out = {}
|
||||
local seen = {}
|
||||
@@ -4879,6 +4907,7 @@ local function _current_ytdl_format_string()
|
||||
local fmt = trim(tostring(mp.get_property_native('ytdl-format') or ''))
|
||||
local suspicious_reason = M._suspicious_ytdl_format_reason(fmt, url, raw)
|
||||
if fmt ~= '' and not suspicious_reason then
|
||||
M._remember_ytdl_download_format(url, fmt)
|
||||
return fmt
|
||||
elseif fmt ~= '' then
|
||||
_lua_log('ytdl-format: ignoring suspicious current format source=ytdl-format value=' .. tostring(fmt) .. ' reason=' .. tostring(suspicious_reason))
|
||||
@@ -4888,6 +4917,7 @@ local function _current_ytdl_format_string()
|
||||
local opt = trim(tostring(mp.get_property('options/ytdl-format') or ''))
|
||||
suspicious_reason = M._suspicious_ytdl_format_reason(opt, url, raw)
|
||||
if opt ~= '' and not suspicious_reason then
|
||||
M._remember_ytdl_download_format(url, opt)
|
||||
return opt
|
||||
elseif opt ~= '' then
|
||||
_lua_log('ytdl-format: ignoring suspicious current format source=options/ytdl-format value=' .. tostring(opt) .. ' reason=' .. tostring(suspicious_reason))
|
||||
@@ -4898,6 +4928,7 @@ local function _current_ytdl_format_string()
|
||||
local raw_format_id = tostring(raw.format_id)
|
||||
suspicious_reason = M._suspicious_ytdl_format_reason(raw_format_id, url, raw)
|
||||
if not suspicious_reason then
|
||||
M._remember_ytdl_download_format(url, raw_format_id)
|
||||
return raw_format_id
|
||||
end
|
||||
_lua_log('ytdl-format: ignoring suspicious current format source=ytdl-raw-info.format_id value=' .. tostring(raw_format_id) .. ' reason=' .. tostring(suspicious_reason))
|
||||
@@ -4914,6 +4945,7 @@ local function _current_ytdl_format_string()
|
||||
local joined = table.concat(parts, '+')
|
||||
suspicious_reason = M._suspicious_ytdl_format_reason(joined, url, raw)
|
||||
if not suspicious_reason then
|
||||
M._remember_ytdl_download_format(url, joined)
|
||||
return joined
|
||||
end
|
||||
_lua_log('ytdl-format: ignoring suspicious current format source=ytdl-raw-info.requested_formats value=' .. tostring(joined) .. ' reason=' .. tostring(suspicious_reason))
|
||||
@@ -4921,6 +4953,17 @@ local function _current_ytdl_format_string()
|
||||
end
|
||||
end
|
||||
|
||||
if url ~= '' and _is_ytdlp_url(url) then
|
||||
local remembered = M._get_remembered_ytdl_download_format(url)
|
||||
suspicious_reason = M._suspicious_ytdl_format_reason(remembered, url, raw)
|
||||
if remembered and not suspicious_reason then
|
||||
_lua_log('ytdl-format: using remembered download fallback value=' .. tostring(remembered) .. ' url=' .. tostring(url))
|
||||
return remembered
|
||||
elseif remembered then
|
||||
_lua_log('ytdl-format: ignoring suspicious remembered fallback value=' .. tostring(remembered) .. ' reason=' .. tostring(suspicious_reason))
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -5200,6 +5243,7 @@ local function _apply_ytdl_format_and_reload(url, fmt)
|
||||
_lua_log('change-format: setting ytdl format=' .. tostring(fmt))
|
||||
_skip_next_store_check_url = _normalize_url_for_store_lookup(url)
|
||||
_set_current_web_url(url)
|
||||
M._remember_ytdl_download_format(url, fmt)
|
||||
pcall(mp.set_property, 'options/ytdl-format', tostring(fmt))
|
||||
pcall(mp.set_property, 'file-local-options/ytdl-format', tostring(fmt))
|
||||
pcall(mp.set_property, 'ytdl-format', tostring(fmt))
|
||||
|
||||
Reference in New Issue
Block a user