summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/lua/autoload.lua96
-rwxr-xr-xTOOLS/matroska.py3
-rwxr-xr-xTOOLS/osxbundle.py9
3 files changed, 92 insertions, 16 deletions
diff --git a/TOOLS/lua/autoload.lua b/TOOLS/lua/autoload.lua
index 7ec6924d31..593d375431 100644
--- a/TOOLS/lua/autoload.lua
+++ b/TOOLS/lua/autoload.lua
@@ -10,6 +10,12 @@
To configure this script use file autoload.conf in directory script-opts (the "script-opts"
directory must be in the mpv configuration directory, typically ~/.config/mpv/).
+Option `ignore_patterns` is a comma-separated list of patterns (see lua.org/pil/20.2.html).
+Additionally to the standard lua patterns, you can also escape commas with `%`,
+for example, the option `bak%,x%,,another` will be resolved as patterns `bak,x,` and `another`.
+But it does not mean you need to escape all lua patterns twice,
+so the option `bak%%,%.mp4,` will be resolved as two patterns `bak%%` and `%.mp4`.
+
Example configuration would be:
disabled=no
@@ -22,6 +28,7 @@ additional_audio_exts=list,of,ext
ignore_hidden=yes
same_type=yes
directory_mode=recursive
+ignore_patterns=^~,^bak-,%.bak$
--]]
@@ -42,7 +49,8 @@ o = {
additional_audio_exts = "",
ignore_hidden = true,
same_type = false,
- directory_mode = "auto"
+ directory_mode = "auto",
+ ignore_patterns = ""
}
options.read_options(o, nil, function(list)
split_option_exts(list.additional_video_exts, list.additional_audio_exts, list.additional_image_exts)
@@ -67,23 +75,59 @@ function SetUnion (a,b)
return a
end
-function Split (s)
+-- Returns first and last positions in string or past-to-end indices
+function FindOrPastTheEnd (string, pattern, start_at)
+ local pos1, pos2 = string.find(string, pattern, start_at)
+ return pos1 or #string + 1,
+ pos2 or #string + 1
+end
+
+function Split (list)
local set = {}
- for v in string.gmatch(s, '([^,]+)') do set[v] = true end
+
+ local item_pos = 1
+ local item = ""
+
+ while item_pos <= #list do
+ local pos1, pos2 = FindOrPastTheEnd(list, "%%*,", item_pos)
+
+ local pattern_length = pos2 - pos1
+ local is_comma_escaped = pattern_length % 2
+
+ local pos_before_escape = pos1 - 1
+ local item_escape_count = pattern_length - is_comma_escaped
+
+ item = item .. string.sub(list, item_pos, pos_before_escape + item_escape_count)
+
+ if is_comma_escaped == 1 then
+ item = item .. ","
+ else
+ set[item] = true
+ item = ""
+ end
+
+ item_pos = pos2 + 1
+ end
+
+ set[item] = true
+
+ -- exclude empty items
+ set[""] = nil
+
return set
end
-EXTENSIONS_VIDEO = Set {
+EXTENSIONS_VIDEO_DEFAULT = Set {
'3g2', '3gp', 'avi', 'flv', 'm2ts', 'm4v', 'mj2', 'mkv', 'mov',
'mp4', 'mpeg', 'mpg', 'ogv', 'rmvb', 'webm', 'wmv', 'y4m'
}
-EXTENSIONS_AUDIO = Set {
+EXTENSIONS_AUDIO_DEFAULT = Set {
'aiff', 'ape', 'au', 'flac', 'm4a', 'mka', 'mp3', 'oga', 'ogg',
'ogm', 'opus', 'wav', 'wma'
}
-EXTENSIONS_IMAGES = Set {
+EXTENSIONS_IMAGES_DEFAULT = Set {
'avif', 'bmp', 'gif', 'j2k', 'jp2', 'jpeg', 'jpg', 'jxl', 'png',
'svg', 'tga', 'tif', 'tiff', 'webp'
}
@@ -95,11 +139,28 @@ function split_option_exts(video, audio, image)
end
split_option_exts(true, true, true)
+function split_patterns()
+ o.ignore_patterns = Split(o.ignore_patterns)
+end
+split_patterns()
+
function create_extensions()
EXTENSIONS = {}
- if o.videos then SetUnion(SetUnion(EXTENSIONS, EXTENSIONS_VIDEO), o.additional_video_exts) end
- if o.audio then SetUnion(SetUnion(EXTENSIONS, EXTENSIONS_AUDIO), o.additional_audio_exts) end
- if o.images then SetUnion(SetUnion(EXTENSIONS, EXTENSIONS_IMAGES), o.additional_image_exts) end
+ EXTENSIONS_VIDEO = {}
+ EXTENSIONS_AUDIO = {}
+ EXTENSIONS_IMAGES = {}
+ if o.videos then
+ SetUnion(SetUnion(EXTENSIONS_VIDEO, EXTENSIONS_VIDEO_DEFAULT), o.additional_video_exts)
+ SetUnion(EXTENSIONS, EXTENSIONS_VIDEO)
+ end
+ if o.audio then
+ SetUnion(SetUnion(EXTENSIONS_AUDIO, EXTENSIONS_AUDIO_DEFAULT), o.additional_audio_exts)
+ SetUnion(EXTENSIONS, EXTENSIONS_AUDIO)
+ end
+ if o.images then
+ SetUnion(SetUnion(EXTENSIONS_IMAGES, EXTENSIONS_IMAGES_DEFAULT), o.additional_image_exts)
+ SetUnion(EXTENSIONS, EXTENSIONS_IMAGES)
+ end
end
create_extensions()
@@ -127,6 +188,16 @@ function get_extension(path)
end
end
+function is_ignored(file)
+ for pattern, _ in pairs(o.ignore_patterns) do
+ if string.match(file, pattern) then
+ return true
+ end
+ end
+
+ return false
+end
+
table.filter = function(t, iter)
for i = #t, 1, -1 do
if not iter(t[i]) then
@@ -177,9 +248,14 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file
table.filter(files, function (v)
-- The current file could be a hidden file, ignoring it doesn't load other
-- files from the current directory.
- if (o.ignore_hidden and not (prefix .. v == current_file) and string.match(v, "^%.")) then
+ local current = prefix .. v == current_file
+ if o.ignore_hidden and not current and string.match(v, "^%.") then
return false
end
+ if not current and is_ignored(v) then
+ return false
+ end
+
local ext = get_extension(v)
if ext == nil then
return false
diff --git a/TOOLS/matroska.py b/TOOLS/matroska.py
index 52bac48c92..61a33ffb84 100755
--- a/TOOLS/matroska.py
+++ b/TOOLS/matroska.py
@@ -92,6 +92,7 @@ elements_matroska = (
'MaxBlockAdditionID, 55ee, uint',
'Name, 536e, str',
'Language, 22b59c, str',
+ 'LanguageBCP47, 22b59d, str',
'CodecID, 86, str',
'CodecPrivate, 63a2, binary',
'CodecName, 258688, str',
@@ -206,6 +207,7 @@ elements_matroska = (
'ChapterDisplay*, 80, sub', (
'ChapString, 85, str',
'ChapLanguage*, 437c, str',
+ 'ChapLanguageBCP47*, 437d, str',
'ChapCountry*, 437e, str',
),
),
@@ -224,6 +226,7 @@ elements_matroska = (
'SimpleTag*, 67c8, sub', (
'TagName, 45a3, str',
'TagLanguage, 447a, str',
+ 'TagLanguageBCP47, 447b, str',
'TagString, 4487, str',
'TagDefault, 4484, uint',
),
diff --git a/TOOLS/osxbundle.py b/TOOLS/osxbundle.py
index fc8379c748..0e156a0b02 100755
--- a/TOOLS/osxbundle.py
+++ b/TOOLS/osxbundle.py
@@ -1,14 +1,11 @@
#!/usr/bin/env python3
import os
import shutil
-import sys
import fileinput
import dylib_unhell
+import subprocess
from optparse import OptionParser
-def sh(command):
- return os.popen(command).read().strip()
-
def bundle_path(binary_name):
return "%s.app" % binary_name
@@ -45,8 +42,8 @@ def sign_bundle(binary_name):
resolved_dir = os.path.join(bundle_path(binary_name), dir)
for root, _dirs, files in os.walk(resolved_dir):
for f in files:
- sh('codesign --force -s - ' + os.path.join(root, f))
- sh('codesign --force -s - ' + bundle_path(binary_name))
+ subprocess.run(['codesign', '--force', '-s', '-', os.path.join(root, f)])
+ subprocess.run(['codesign', '--force', '-s', '-', bundle_path(binary_name)])
def bundle_version(src_path):
version = 'UNKNOWN'