diff --git a/clean-playlist.lua b/clean-playlist.lua index 6d96c2e..92e346c 100644 --- a/clean-playlist.lua +++ b/clean-playlist.lua @@ -1,33 +1,26 @@ +local ext = { + "mkv","mp4","webm","wmv","avi","3gp","ogv","mpg","mpeg","mov","vob" ,"ts","m2ts","divx","flv","asf","m4v","h264","h265","rmvb","rm","ogm" +} + +local valid = {} +for i = 1, #ext do + valid[ext[i]] = true +end + local function main() local playlist = mp.get_property_native('playlist') local skipCurrent = false for i = #playlist, 1, -1 do local ext = string.match(playlist[i].filename, "%.([^.]+)$") - if(ext ~= nil) then - ext = ext:lower() - if( ext ~= "mkv" - and ext ~= "mp4" - and ext ~= "webm" - and ext ~= "wmv" - and ext ~= "avi" - and ext ~= "mpg" - and ext ~= "mpeg" - and ext ~= "mov" - and ext ~= "vob" - and ext ~= "ts" - and ext ~= "m2ts" - and ext ~= "divx" - and ext ~= "flv" - and ext ~= "asf" - and ext ~= "m4v" - and ext ~= "h264" - and ext ~= "rmvb" - and ext ~= "ogm") then - if(playlist[i].current) then - skipCurrent = true - else - mp.commandv('playlist-remove',i-1) - end + if(ext == nil) then ext = '' end + ext = string.lower(ext) + if(valid[ext]) then + --do nothing + else + if(playlist[i].current) then + skipCurrent = true + else + mp.commandv('playlist-remove',i-1) end end end