mirror of
https://github.com/mpv-player/mpv
synced 2025-01-14 02:51:26 +00:00
TOOLS/lua/autoload: add directory_mode option
This option behaves the same as the builtin one, and if it's value is anything other then recursive|lazy|ignore it will fall back on the builtin one as a sort of "auto" mode. It defaults to that auto mode.
This commit is contained in:
parent
5100e7acba
commit
da400ed3a9
@ -21,6 +21,7 @@ additional_video_exts=list,of,ext
|
||||
additional_audio_exts=list,of,ext
|
||||
ignore_hidden=yes
|
||||
same_type=yes
|
||||
directory_mode=recursive
|
||||
|
||||
--]]
|
||||
|
||||
@ -40,7 +41,8 @@ o = {
|
||||
additional_video_exts = "",
|
||||
additional_audio_exts = "",
|
||||
ignore_hidden = true,
|
||||
same_type = false
|
||||
same_type = false,
|
||||
directory_mode = "auto"
|
||||
}
|
||||
options.read_options(o, nil, function(list)
|
||||
split_option_exts(list.additional_video_exts, list.additional_audio_exts, list.additional_image_exts)
|
||||
@ -49,6 +51,9 @@ options.read_options(o, nil, function(list)
|
||||
list.images or list.additional_image_exts then
|
||||
create_extensions()
|
||||
end
|
||||
if list.directory_mode then
|
||||
validate_directory_mode()
|
||||
end
|
||||
end)
|
||||
|
||||
function Set (t)
|
||||
@ -98,6 +103,13 @@ function create_extensions()
|
||||
end
|
||||
create_extensions()
|
||||
|
||||
function validate_directory_mode()
|
||||
if o.directory_mode ~= "recursive" and o.directory_mode ~= "lazy" and o.directory_mode ~= "ignore" then
|
||||
o.directory_mode = nil
|
||||
end
|
||||
end
|
||||
validate_directory_mode()
|
||||
|
||||
function add_files(files)
|
||||
local oldcount = mp.get_property_number("playlist-count", 1)
|
||||
for i = 1, #files do
|
||||
@ -244,7 +256,7 @@ function find_and_add_entries()
|
||||
|
||||
local files = {}
|
||||
do
|
||||
local dir_mode = mp.get_property("directory-mode")
|
||||
local dir_mode = o.directory_mode or mp.get_property("directory-mode", "lazy")
|
||||
local separator = mp.get_property_native("platform") == "windows" and "\\" or "/"
|
||||
scan_dir(autoloaded_dir, path, dir_mode, separator, 0, files)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user