@@ -77,7 +77,10 @@ local options = {
77
77
local_pattern = " " ,
78
78
79
79
-- Legacy option, use skip_categories instead
80
- skip = true
80
+ skip = true ,
81
+
82
+ -- Decide whether or not to show text when sponsoblocks triggers an action
83
+ osd_text_show = false
81
84
}
82
85
83
86
mp .options = require " mp.options"
@@ -137,7 +140,8 @@ function parse_update_interval()
137
140
local num , mod = s :match " ^(%d+)([hdm])$"
138
141
139
142
if num == nil or mod == nil then
140
- mp .osd_message (" [sponsorblock] auto_update_interval " .. s .. " is invalid" , 5 )
143
+ local osd_text = osd_show (" [sponsorblock] auto_update_interval " .. s .. " is invalid" , 5 )
144
+ mp .osd_message ()
141
145
return nil
142
146
end
143
147
@@ -150,6 +154,13 @@ function parse_update_interval()
150
154
return num * time_table [mod ]
151
155
end
152
156
157
+ function osd_show (text )
158
+ local s = options .osd_text_show
159
+ if s == false then return " " end
160
+
161
+ return text ;
162
+ end
163
+
153
164
function clean_chapters ()
154
165
local chapters = mp .get_property_native (" chapter-list" )
155
166
local new_chapters = {}
@@ -282,10 +293,12 @@ function skip_ads(name, pos)
282
293
if (options .fast_forward == uuid or not options .skip_once or not t .skipped ) and t .start_time <= pos and t .end_time > pos then
283
294
if options .fast_forward == uuid then return end
284
295
if options .fast_forward == false then
285
- mp .osd_message (" [sponsorblock] " .. t .category .. " skipped" )
296
+ local osd_text = osd_show (" [sponsorblock] " .. t .category .. " skipped" )
297
+ mp .osd_message (osd_text )
286
298
mp .set_property (" time-pos" , t .end_time )
287
299
else
288
- mp .osd_message (" [sponsorblock] skipping " .. t .category )
300
+ local osd_text = osd_show (" [sponsorblock] skipping " .. t .category )
301
+ mp .osd_message (osd_text )
289
302
end
290
303
t .skipped = true
291
304
last_skip = {uuid = uuid , dir = nil }
@@ -342,9 +355,15 @@ function skip_ads(name, pos)
342
355
end
343
356
344
357
function vote (dir )
345
- if last_skip .uuid == " " then return mp .osd_message (" [sponsorblock] no sponsors skipped, can't submit vote" ) end
358
+ if last_skip .uuid == " " then
359
+ local osd_text = osd_show (" [sponsorblock] no sponsors skipped, can't submit vote" )
360
+ return mp .osd_message (osd_text )
361
+ end
346
362
local updown = dir == " 1" and " up" or " down"
347
- if last_skip .dir == dir then return mp .osd_message (" [sponsorblock] " .. updown .. " vote already submitted" ) end
363
+ if last_skip .dir == dir then
364
+ local osd_text = osd_show (" [sponsorblock] " .. updown .. " vote already submitted" )
365
+ return mp .osd_message (osd_text )
366
+ end
348
367
last_skip .dir = dir
349
368
local args = {
350
369
options .python_path ,
@@ -364,7 +383,8 @@ function vote(dir)
364
383
else
365
384
utils .subprocess ({args = args })
366
385
end
367
- mp .osd_message (" [sponsorblock] " .. updown .. " vote submitted" )
386
+ local osd_text = osd_show (" [sponsorblock] " .. updown .. " vote submitted" )
387
+ mp .osd_message (osd_text )
368
388
end
369
389
370
390
function update ()
@@ -463,11 +483,13 @@ function set_segment()
463
483
if segment .progress == 1 then
464
484
segment .progress = 0
465
485
segment .b = pos
466
- mp .osd_message (" [sponsorblock] segment boundary B set, press again for boundary A" , 3 )
486
+ local osd_text = osd_show (" [sponsorblock] segment boundary B set, press again for boundary A" )
487
+ mp .osd_message (osd_text , 3 )
467
488
else
468
489
segment .progress = 1
469
490
segment .a = pos
470
- mp .osd_message (" [sponsorblock] segment boundary A set, press again for boundary B" , 3 )
491
+ local osd_text = osd_show (" [sponsorblock] segment boundary A set, press again for boundary B" )
492
+ mp .osd_message (osd_text , 3 )
471
493
end
472
494
if options .make_chapters and not segment .first then
473
495
local start_time = math.min (segment .a , segment .b )
@@ -494,7 +516,8 @@ function submit_segment(category)
494
516
local start_time = math.min (segment .a , segment .b )
495
517
local end_time = math.max (segment .a , segment .b )
496
518
if end_time - start_time == 0 or end_time == 0 then
497
- mp .osd_message (" [sponsorblock] empty segment, not submitting" )
519
+ local osd_text = osd_show (" [sponsorblock] empty segment, not submitting" )
520
+ mp .osd_message (osd_text )
498
521
elseif segment .progress <= 1 then
499
522
segment .progress = segment .progress + 2
500
523
local category_list = " "
@@ -504,9 +527,11 @@ function submit_segment(category)
504
527
mp .add_forced_key_binding (tostring (category_id ), " select_category_" .. category , function () select_category (category ) end )
505
528
mp .add_forced_key_binding (" KP" .. tostring (category_id ), " kp_select_category_" .. category , function () select_category (category ) end )
506
529
end
507
- mp .osd_message (string.format (" [sponsorblock] press a number to select category for segment: %.2d:%.2d:%.2d to %.2d:%.2d:%.2d\n\n " .. category_list .. " \n you can press Shift+G again for default (Sponsor) or hide this message with g" , math.floor (start_time / (60 * 60 )), math.floor (start_time / 60 % 60 ), math.floor (start_time % 60 ), math.floor (end_time / (60 * 60 )), math.floor (end_time / 60 % 60 ), math.floor (end_time % 60 )), 30 )
530
+ local osd_text = osd_show (string.format (" [sponsorblock] press a number to select category for segment: %.2d:%.2d:%.2d to %.2d:%.2d:%.2d\n\n " .. category_list .. " \n you can press Shift+G again for default (Sponsor) or hide this message with g" , math.floor (start_time / (60 * 60 )), math.floor (start_time / 60 % 60 ), math.floor (start_time % 60 ), math.floor (end_time / (60 * 60 )), math.floor (end_time / 60 % 60 ), math.floor (end_time % 60 )))
531
+ mp .osd_message (osd_text , 30 )
508
532
else
509
- mp .osd_message (" [sponsorblock] submitting segment..." , 30 )
533
+ local osd_text = osd_show (" [sponsorblock] submitting segment..." )
534
+ mp .osd_message (osd_text , 30 )
510
535
local submit
511
536
local args = {
512
537
options .python_path ,
@@ -528,26 +553,33 @@ function submit_segment(category)
528
553
end
529
554
if string.match (submit .stdout , " success" ) then
530
555
segment = {a = 0 , b = 0 , progress = 0 , first = true }
531
- mp .osd_message (" [sponsorblock] segment submitted" )
556
+ local osd_text = osd_show (" [sponsorblock] segment submitted" )
557
+ mp .osd_message (osd_text )
532
558
if options .make_chapters then
533
559
clean_chapters ()
534
560
create_chapter (" Submitted segment start" , start_time )
535
561
create_chapter (" Submitted segment end" , end_time )
536
562
end
537
563
elseif string.match (submit .stdout , " error" ) then
538
- mp .osd_message (" [sponsorblock] segment submission failed, server may be down. try again" , 5 )
564
+ local osd_text = osd_show (" [sponsorblock] segment submission failed, server may be down. try again" , 5 )
565
+ mp .osd_message ()
539
566
elseif string.match (submit .stdout , " 502" ) then
540
- mp .osd_message (" [sponsorblock] segment submission failed, server is down. try again" , 5 )
567
+ local osd_text = osd_show (" [sponsorblock] segment submission failed, server is down. try again" , 5 )
568
+ mp .osd_message ()
541
569
elseif string.match (submit .stdout , " 400" ) then
542
- mp .osd_message (" [sponsorblock] segment submission failed, impossible inputs" , 5 )
570
+ local osd_text = osd_show (" [sponsorblock] segment submission failed, impossible inputs" , 5 )
571
+ mp .osd_message ()
543
572
segment = {a = 0 , b = 0 , progress = 0 , first = true }
544
573
elseif string.match (submit .stdout , " 429" ) then
545
- mp .osd_message (" [sponsorblock] segment submission failed, rate limited. try again" , 5 )
574
+ local osd_text = osd_show (" [sponsorblock] segment submission failed, rate limited. try again" , 5 )
575
+ mp .osd_message ()
546
576
elseif string.match (submit .stdout , " 409" ) then
547
- mp .osd_message (" [sponsorblock] segment already submitted" , 3 )
577
+ local osd_text = osd_show (" [sponsorblock] segment already submitted" , 3 )
578
+ mp .osd_message ()
548
579
segment = {a = 0 , b = 0 , progress = 0 , first = true }
549
580
else
550
- mp .osd_message (" [sponsorblock] segment submission failed" , 5 )
581
+ local osd_text = osd_show (" [sponsorblock] segment submission failed" , 5 )
582
+ mp .osd_message ()
551
583
end
552
584
end
553
585
end
0 commit comments