mpv2oboeru

mpv helpers to create flashcards from movies and TV shows
git clone anongit@rnpnr.xyz:mpv2oboeru.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 4592698f38128aec1cb637ad5165ef6e44707d57
Parent: 83a1715c491d7fa692a1b61b43919c3d570cade1
Author: Ren Tatsumoto
Date:   Sun, 24 Jan 2021 12:18:54 +0300

conditionally set defaults

Diffstat:
Msubs2srs.lua | 22+++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/subs2srs.lua b/subs2srs.lua @@ -314,22 +314,26 @@ do config[dimension] = config[dimension] > 640 and 640 or config[dimension] end - local function check_snapshot_settings() - ensure_in_range('snapshot_width') - ensure_in_range('snapshot_height') - if config.snapshot_width < 1 and config.snapshot_height < 1 then - config.snapshot_width = -2 - config.snapshot_height = 200 + local function conditionally_set_defaults(width, height, quality) + if config[width] < 1 and config[height] < 1 then + config[width] = -2 + config[height] = 200 end - if config.snapshot_quality < 0 or config.snapshot_quality > 100 then - config.snapshot_quality = 15 + if config[quality] < 0 or config[quality] > 100 then + config[quality] = 15 end end + local function check_image_settings() + ensure_in_range('snapshot_width') + ensure_in_range('snapshot_height') + conditionally_set_defaults('snapshot_width', 'snapshot_height', 'snapshot_quality') + end + validate_config = function() set_audio_format() set_video_format() - check_snapshot_settings() + check_image_settings() end end