diff options
author | sunpenghao <sunpenghao1997@outlook.com> | 2023-08-18 01:23:45 +0800 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-08-19 04:00:25 +0000 |
commit | f6fc6cfd35de50c281bd57e735ced22711f52c64 (patch) | |
tree | 829ea38f9ae3b11e3affbbc2c2d89cc429dd3cec /TOOLS | |
parent | 152a95f2151985a19408cd46dcfff3457b19773d (diff) | |
download | mpv-f6fc6cfd35de50c281bd57e735ced22711f52c64.tar.bz2 mpv-f6fc6cfd35de50c281bd57e735ced22711f52c64.tar.xz |
TOOLS/lua/autoload: may specify loading only one type of files
Under the current file loading logic, a video file and an external
audio track next to it will both be added to the playlist, which
most users don't wish to happen. Having an option that tells the
script to load only one type of files (video, audio, or image)
can avoid this problem. It may also come in handy for people who
have different types of files mixed in a folder but wish to consume
only one type of media at a time.
Diffstat (limited to 'TOOLS')
-rw-r--r-- | TOOLS/lua/autoload.lua | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/TOOLS/lua/autoload.lua b/TOOLS/lua/autoload.lua index 6d50651222..cc39c7c6cf 100644 --- a/TOOLS/lua/autoload.lua +++ b/TOOLS/lua/autoload.lua @@ -20,6 +20,7 @@ additional_image_exts=list,of,ext additional_video_exts=list,of,ext additional_audio_exts=list,of,ext ignore_hidden=yes +same_type=yes --]] @@ -37,7 +38,8 @@ o = { additional_image_exts = "", additional_video_exts = "", additional_audio_exts = "", - ignore_hidden = true + ignore_hidden = true, + same_type = false } options.read_options(o) @@ -153,15 +155,28 @@ function find_and_add_entries() end pl_count = mp.get_property_number("playlist-count", 1) + this_ext = get_extension(filename) -- check if this is a manually made playlist if (pl_count > 1 and autoloaded == nil) or - (pl_count == 1 and EXTENSIONS[string.lower(get_extension(filename))] == nil) then + (pl_count == 1 and EXTENSIONS[string.lower(this_ext)] == nil) then msg.verbose("stopping: manually made playlist") return else autoloaded = true end + if o.same_type then + if EXTENSIONS_VIDEO[string.lower(this_ext)] ~= nil then + EXTENSIONS_TARGET = EXTENSIONS_VIDEO + elseif EXTENSIONS_AUDIO[string.lower(this_ext)] ~= nil then + EXTENSIONS_TARGET = EXTENSIONS_AUDIO + else + EXTENSIONS_TARGET = EXTENSIONS_IMAGES + end + else + EXTENSIONS_TARGET = EXTENSIONS + end + local pl = mp.get_property_native("playlist", {}) local pl_current = mp.get_property_number("playlist-pos-1", 1) msg.trace(("playlist-pos-1: %s, playlist: %s"):format(pl_current, @@ -182,7 +197,7 @@ function find_and_add_entries() if ext == nil then return false end - return EXTENSIONS[string.lower(ext)] + return EXTENSIONS_TARGET[string.lower(ext)] end) alphanumsort(files) |