Skip to content

Commit d0f0f0b

Browse files
authored
SmartSkip.lua
feat: added smart_next_proceed_countdown and smart_prev_cancel_countdown user config. Changed autoskip function to utilize proceed_autoskip function which is also used for smart_next_proceed_countdown. This also resolved some improper osd not showing when using proceed_countdown keybind because it did not have the full function as per the timeout.
1 parent 52edfcd commit d0f0f0b

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

scripts/SmartSkip.lua

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
-- License: BSD 2-Clause License
33
-- Creator: Eisa AlAwadhi
44
-- Project: SmartSkip
5-
-- Version: 1.17
6-
-- Date: 20-09-2023
5+
-- Version: 1.18
6+
-- Date: 21-09-2023
77

88
-- Related forked projects:
99
-- https://github.com/detuur/mpv-scripts/blob/master/skiptosilence.lua
@@ -24,6 +24,8 @@ local o = {
2424
force_mute_on_skip = false,
2525
--SmartSkip user config--
2626
last_chapter_skip_behavior=[[ [ ["no-chapters", "silence-skip"], ["internal-chapters", "playlist-next"], ["external-chapters", "silence-skip"] ] ]],--1.09# Available options [[ [ ["no-chapters", "silence-skip"], ["internal-chapters", "playlist-next"], ["external-chapters", "chapter-next"] ] ]] -- it defaults to silence-skip so if dont define external-chapters it will be silence-skip
27+
smart_next_proceed_countdown = true, --1.18# if autoskip countdown is active, proceeds to autoskip as the next action
28+
smart_prev_cancel_countdown = false, --1.18# if autoskip countdown is active, smart_prev will cancel autoskip countdown without going backwards
2729
--chapters user config--
2830
external_chapters_autoload = true, --0.15# rename
2931
modified_chapters_autosave=[[ ["no-chapters", "external-chapters"] ]], --1.06# add the following options --- (yes/no) or specify types ["no-chapters", "internal-chapters", "external-chapters"])
@@ -281,6 +283,7 @@ end
281283

282284
-- smart-skip main code --
283285
function smartNext()
286+
if g_autoskip_countdown_flag and o.smart_next_proceed_countdown then proceed_autoskip(true) return end --1.18# proceed_autoskip using smartNext if countdown started
284287
local next_action = "silence-skip"
285288
local chapters_count = (mp.get_property_number('chapters') or 0)
286289
local chapter = (mp.get_property_number('chapter') or 0)
@@ -320,6 +323,7 @@ end
320323

321324
function smartPrev()
322325
if skip_flag then restoreProp(initial_skip_time) return end
326+
if g_autoskip_countdown_flag and o.smart_prev_cancel_countdown then kill_chapterskip_countdown('osd') return end --1.18# kill auto-skip if its on-going when using smartPrev
323327
local chapters_count = (mp.get_property_number('chapters') or 0)
324328
local chapter = (mp.get_property_number('chapter') or 0)
325329
local timepos = (mp.get_property_native("time-pos") or 0)
@@ -1269,18 +1273,6 @@ function chapterskip(_, current, countdown)
12691273
elseif skip and countdown > 0 then
12701274
g_autoskip_countdown_flag = true
12711275
bind_keys(o.cancel_autoskip_countdown_keybind, "cancel-autoskip-countdown", function() kill_chapterskip_countdown('osd') return end)
1272-
bind_keys(o.proceed_autoskip_countdown_keybind, "proceed-autoskip-countdown", function()
1273-
kill_chapterskip_countdown()
1274-
if consecutive_i > 1 and o.autoskip_countdown_bulk then
1275-
chapterskip(_,current,0)
1276-
return
1277-
else
1278-
prompt_msg('➤ Auto-Skip: Chapter '.. mp.command_native({'expand-text', '${chapter}'}))
1279-
mp.set_property("time-pos", chapters[i-consecutive_i+1].time)
1280-
skipped[skip] = true
1281-
return
1282-
end
1283-
end)
12841276

12851277
local autoskip_osd_string = ''
12861278
local autoskip_graceful_osd = ''
@@ -1305,9 +1297,9 @@ function chapterskip(_, current, countdown)
13051297
end
13061298
end
13071299
if o.autoskip_countdown_graceful then return end
1308-
mp.add_timeout(countdown, function()
1300+
function proceed_autoskip(force) --1.18# convert it into function so we may bind it to keybind, and also use it for smartNext
13091301
if not g_autoskip_countdown_flag then kill_chapterskip_countdown() return end
1310-
if g_autoskip_countdown > 1 then return end
1302+
if g_autoskip_countdown > 1 and not force then return end --1.18# add option to force it by passing it as true
13111303

13121304
mp.set_property('osd-duration', o.osd_duration)
13131305
mp.commandv(autoskip_osd, "show-progress")
@@ -1332,7 +1324,9 @@ function chapterskip(_, current, countdown)
13321324
end
13331325
skipped[skip] = true
13341326
kill_chapterskip_countdown()
1335-
end)
1327+
end
1328+
mp.add_timeout(countdown, proceed_autoskip) --1.18# bind the function instead
1329+
bind_keys(o.proceed_autoskip_countdown_keybind, "proceed-autoskip-countdown", function() proceed_autoskip(true) return end) --1.18# bind proceed with force and return
13361330
return
13371331
end
13381332
end
@@ -1345,11 +1339,7 @@ function chapterskip(_, current, countdown)
13451339
elseif skip and countdown > 0 then
13461340
g_autoskip_countdown_flag = true
13471341
bind_keys(o.cancel_autoskip_countdown_keybind, "cancel-autoskip-countdown", function() kill_chapterskip_countdown('osd') return end)
1348-
bind_keys(o.proceed_autoskip_countdown_keybind, "proceed-autoskip-countdown", function()
1349-
kill_chapterskip_countdown()
1350-
chapterskip(_,current,0)
1351-
return
1352-
end)
1342+
13531343
if o.autoskip_osd == 'osd-msg-bar' or o.autoskip_osd == 'osd-msg' then
13541344
local autoskip_graceful_osd = ''
13551345
if o.autoskip_countdown_graceful then autoskip_graceful_osd = 'Press Keybind to:\n' end
@@ -1373,10 +1363,10 @@ function chapterskip(_, current, countdown)
13731363
end
13741364
end
13751365
if o.autoskip_countdown_graceful then return end
1376-
mp.add_timeout(countdown, function()
1366+
function proceed_autoskip(force) --1.18# convert it into function so we may bind it to keybind, and also use it for smartNext
13771367
if not g_autoskip_countdown_flag then return end
1378-
if g_autoskip_countdown > 1 then return end
1379-
1368+
if g_autoskip_countdown > 1 and not force then return end --1.18# add option to force it by passing it as true
1369+
13801370
mp.set_property('osd-duration', o.osd_duration) --1.17# show osd-bar as per defined duration
13811371
mp.commandv(autoskip_osd, "show-progress")
13821372
mp.add_timeout(0.07, function () mp.set_property('osd-duration', osd_duration_default) end)
@@ -1400,7 +1390,9 @@ function chapterskip(_, current, countdown)
14001390
end
14011391
if o.autoskip_osd ~= 'no-osd' then autoskip_playlist_osd = true end
14021392
kill_chapterskip_countdown()
1403-
end)
1393+
end
1394+
mp.add_timeout(countdown, proceed_autoskip) --1.18# bind the function instead
1395+
bind_keys(o.proceed_autoskip_countdown_keybind, "proceed-autoskip-countdown", function() proceed_autoskip(true) return end) --1.18# bind proceed with force and return
14041396
end
14051397
end
14061398

0 commit comments

Comments
 (0)