TOOLS/lua/autoload: allow extending ext sets from script-opts

This commit is contained in:
llyyr 2023-07-04 20:45:20 +05:30 committed by Dudemanguy
parent ee69d99bd4
commit 9ad14e0886
1 changed files with 16 additions and 0 deletions

View File

@ -16,6 +16,9 @@ disabled=no
images=no
videos=yes
audio=yes
additional_image_exts=list,of,ext
additional_video_exts=list,of,ext
additional_audio_exts=list,of,ext
ignore_hidden=yes
--]]
@ -31,6 +34,9 @@ o = {
images = true,
videos = true,
audio = true,
additional_image_exts = "",
additional_video_exts = "",
additional_audio_exts = "",
ignore_hidden = true
}
options.read_options(o)
@ -48,6 +54,12 @@ function SetUnion (a,b)
return res
end
function Split (s)
local set = {}
for v in string.gmatch(s, '([^,]+)') do set[v] = true end
return set
end
EXTENSIONS_VIDEO = Set {
'3g2', '3gp', 'avi', 'flv', 'm2ts', 'm4v', 'mj2', 'mkv', 'mov',
'mp4', 'mpeg', 'mpg', 'ogv', 'rmvb', 'webm', 'wmv', 'y4m'
@ -63,6 +75,10 @@ EXTENSIONS_IMAGES = Set {
'svg', 'tga', 'tif', 'tiff', 'webp'
}
EXTENSIONS_VIDEO = SetUnion(EXTENSIONS_VIDEO, Split(o.additional_video_exts))
EXTENSIONS_AUDIO = SetUnion(EXTENSIONS_AUDIO, Split(o.additional_audio_exts))
EXTENSIONS_IMAGES = SetUnion(EXTENSIONS_IMAGES, Split(o.additional_image_exts))
EXTENSIONS = Set {}
if o.videos then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_VIDEO) end
if o.audio then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_AUDIO) end