Skip to content

Commit

Permalink
Update libs, modify accordingly, improve default template
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAMM committed Sep 29, 2018
1 parent a08828f commit cfba432
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libs
11 changes: 6 additions & 5 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function expand_output_path(cropbox)
local playback_time = mp.get_property_native("playback-time")
local duration = mp.get_property_native("duration")

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

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

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

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

Expand Down Expand Up @@ -111,8 +111,8 @@ function screenshot(crop)
-- Optionally create directories
if option_values.create_directories then
local paths = {}
paths[1] = split_path(output_path)
paths[2] = split_path(temporary_screenshot_path)
paths[1] = path_utils.dirname(output_path)
paths[2] = path_utils.dirname(temporary_screenshot_path)

-- Check if we can read the paths
for i, path in ipairs(paths) do
Expand Down Expand Up @@ -162,6 +162,7 @@ function screenshot(crop)
local cmd = {
args = {
"mpv", input_path,
"--no-config",
"--vf=crop=" .. crop_string,
"--frames=1",
"--ovc=" .. option_values.output_format,
Expand Down
2 changes: 1 addition & 1 deletion src/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local option_values = script_options.values
script_options:add_options({
{nil, nil, "mpv_crop_script.lua options and default values"},
{nil, nil, "Output options #", true},
{"output_template", "${filename} ${#pos:%02h.%02m.%06.3s} ${!full:${crop_w}x${crop_h} ${%unique:%03d}}.${ext}",
{"output_template", "${filename}${!is_image: ${#pos:%02h.%02m.%06.3s}}${!full: ${crop_w}x${crop_h}} ${%unique:%03d}.${ext}",
"Filename output template. See README.md for property expansion documentation."},
{nil, nil, [[Script-provided properties:
filename - filename without extension
Expand Down

0 comments on commit cfba432

Please sign in to comment.