Skip to content

Commit cfba432

Browse files
committed
Update libs, modify accordingly, improve default template
1 parent a08828f commit cfba432

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/main.lua

+6-5
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ function expand_output_path(cropbox)
4242
local playback_time = mp.get_property_native("playback-time")
4343
local duration = mp.get_property_native("duration")
4444

45-
local filename_without_ext, extension = split_extension(filename)
45+
local filename_without_ext, extension = filename:match("^(.+)%.(.-)$")
4646

4747
local properties = {
4848
path = mp.get_property_native("path"), -- Original path
4949

50-
filename = filename_without_ext, -- Filename without extension
51-
file_ext = extension, -- Original extension without leading dot (or empty string)
50+
filename = filename_without_ext or filename, -- Filename without extension (or filename if no dots
51+
file_ext = extension or "", -- Original extension without leading dot (or empty string)
5252

5353
pos = mp.get_property_native("playback-time"),
5454

@@ -111,8 +111,8 @@ function screenshot(crop)
111111
-- Optionally create directories
112112
if option_values.create_directories then
113113
local paths = {}
114-
paths[1] = split_path(output_path)
115-
paths[2] = split_path(temporary_screenshot_path)
114+
paths[1] = path_utils.dirname(output_path)
115+
paths[2] = path_utils.dirname(temporary_screenshot_path)
116116

117117
-- Check if we can read the paths
118118
for i, path in ipairs(paths) do
@@ -162,6 +162,7 @@ function screenshot(crop)
162162
local cmd = {
163163
args = {
164164
"mpv", input_path,
165+
"--no-config",
165166
"--vf=crop=" .. crop_string,
166167
"--frames=1",
167168
"--ovc=" .. option_values.output_format,

src/options.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ local option_values = script_options.values
1313
script_options:add_options({
1414
{nil, nil, "mpv_crop_script.lua options and default values"},
1515
{nil, nil, "Output options #", true},
16-
{"output_template", "${filename} ${#pos:%02h.%02m.%06.3s} ${!full:${crop_w}x${crop_h} ${%unique:%03d}}.${ext}",
16+
{"output_template", "${filename}${!is_image: ${#pos:%02h.%02m.%06.3s}}${!full: ${crop_w}x${crop_h}} ${%unique:%03d}.${ext}",
1717
"Filename output template. See README.md for property expansion documentation."},
1818
{nil, nil, [[Script-provided properties:
1919
filename - filename without extension

0 commit comments

Comments
 (0)