diff options
Diffstat (limited to 'TOOLS')
-rw-r--r-- | TOOLS/lua/autoload.lua | 41 | ||||
-rw-r--r-- | TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf | 3 | ||||
-rwxr-xr-x | TOOLS/umpv | 2 |
3 files changed, 42 insertions, 4 deletions
diff --git a/TOOLS/lua/autoload.lua b/TOOLS/lua/autoload.lua index 433b2138d7..0730397e75 100644 --- a/TOOLS/lua/autoload.lua +++ b/TOOLS/lua/autoload.lua @@ -7,6 +7,17 @@ -- Add at most 5 * 2 files when starting a file (before + after). MAXENTRIES = 5 +function Set (t) + local set = {} + for _, v in pairs(t) do set[v] = true end + return set +end + +EXTENSIONS = Set { + 'mkv', 'avi', 'mp4', 'ogv', 'webm', 'rmvb', 'flv', 'wmv', 'mpeg', 'mpg', 'm4v', '3gp', + 'mp3', 'wav', 'ogv', 'flac', 'm4a', 'wma', +} + mputils = require 'mp.utils' function add_files_at(index, files) @@ -18,20 +29,44 @@ function add_files_at(index, files) end end +function get_extension(path) + return string.match(path, "%.([^%.]+)$" ) +end + +table.filter = function(t, iter) + for i = #t, 1, -1 do + if not iter(t[i]) then + table.remove(t, i) + end + end +end + function find_and_add_entries() local path = mp.get_property("path", "") local dir, filename = mputils.split_path(path) if #dir == 0 then return end + local files = mputils.readdir(dir, "files") if files == nil then return end - table.sort(files) + table.filter(files, function (v, k) + local ext = get_extension(v) + if ext == nil then + return false + end + return EXTENSIONS[string.lower(ext)] + end) + table.sort(files, function (a, b) + return string.lower(a) < string.lower(b) + end) + if dir == "." then dir = "" end + local pl = mp.get_property_native("playlist", {}) local pl_current = mp.get_property_number("playlist-pos", 0) + 1 -- Find the current pl entry (dir+"/"+filename) in the sorted dir list @@ -45,6 +80,7 @@ function find_and_add_entries() if current == nil then return end + local append = {[-1] = {}, [1] = {}} for direction = -1, 1, 2 do -- 2 iterations, with direction = -1 and +1 for i = 1, MAXENTRIES do @@ -53,6 +89,7 @@ function find_and_add_entries() if file == nil or file[1] == "." then break end + local filepath = dir .. file if pl_e then -- If there's a playlist entry, and it's the same file, stop. @@ -60,6 +97,7 @@ function find_and_add_entries() break end end + if direction == -1 then if pl_current == 1 then -- never add additional entries in the middle mp.msg.info("Prepending " .. file) @@ -71,6 +109,7 @@ function find_and_add_entries() end end end + add_files_at(pl_current + 1, append[1]) add_files_at(pl_current, append[-1]) end diff --git a/TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf b/TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf index ff78dfacf6..7527de0d1b 100644 --- a/TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf +++ b/TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf @@ -1,3 +1,2 @@ screenshot-template=~/Desktop/shot%n -quiet -idle=once +profile=pseudo-gui diff --git a/TOOLS/umpv b/TOOLS/umpv index 4757e4b370..0080b44ffb 100755 --- a/TOOLS/umpv +++ b/TOOLS/umpv @@ -21,7 +21,7 @@ script after that will start a new mpv instance. Note that you can control the mpv instance by writing to the command fifo: - echo "cycle fullscreen" > ~/.umpv-fifo + echo "cycle fullscreen" > ~/.umpv_fifo Note: you can supply custom mpv path and options with the MPV environment variable. The environment variable will be split on whitespace, and the |