summaryrefslogtreecommitdiffstats
path: root/TOOLS/lua/autoload.lua
diff options
context:
space:
mode:
Diffstat (limited to 'TOOLS/lua/autoload.lua')
-rw-r--r--TOOLS/lua/autoload.lua23
1 files changed, 14 insertions, 9 deletions
diff --git a/TOOLS/lua/autoload.lua b/TOOLS/lua/autoload.lua
index 392ccdff37..048ecdedb0 100644
--- a/TOOLS/lua/autoload.lua
+++ b/TOOLS/lua/autoload.lua
@@ -127,6 +127,16 @@ end
local autoloaded = nil
+function get_playlist_filenames()
+ local filenames = {}
+ for n = 0, pl_count - 1, 1 do
+ local filename = mp.get_property('playlist/'..n..'/filename')
+ local _, file = utils.split_path(filename)
+ filenames[file] = true
+ end
+ return filenames
+end
+
function find_and_add_entries()
local path = mp.get_property("path", "")
local dir, filename = utils.split_path(path)
@@ -139,7 +149,7 @@ function find_and_add_entries()
return
end
- local pl_count = mp.get_property_number("playlist-count", 1)
+ pl_count = mp.get_property_number("playlist-count", 1)
-- 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
@@ -191,22 +201,17 @@ function find_and_add_entries()
msg.trace("current file position in files: "..current)
local append = {[-1] = {}, [1] = {}}
+ local filenames = get_playlist_filenames()
for direction = -1, 1, 2 do -- 2 iterations, with direction = -1 and +1
for i = 1, MAXENTRIES do
local file = files[current + i * direction]
- local pl_e = pl[pl_current + i * direction]
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.
- msg.trace(pl_e.filename.." == "..filepath.." ?")
- if pl_e.filename == filepath then
- break
- end
- end
+ -- skip files already in playlist
+ if filenames[file] then break end
if direction == -1 then
if pl_current == 1 then -- never add additional entries in the middle