mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-15 01:03:40 +01:00
rework mpv sbskip script
This commit is contained in:
parent
377a7c058e
commit
ab61721503
1 changed files with 17 additions and 7 deletions
|
@ -3,13 +3,26 @@
|
|||
|
||||
;; MPV script to skip SponsorBlock segments added by yt-dlp's `--sponsorblock-mark=all` option
|
||||
|
||||
;; list of SponsorBlock segment types NOT to skip
|
||||
(local blacklist [:Highlight])
|
||||
;; list of SponsorBlock segment types to skip
|
||||
(local blacklist [:Intro :Sponsor :Outro :Endcards/Credits :Inermission])
|
||||
|
||||
;; chapters alredy skipped this file
|
||||
;; table of chapter id => true
|
||||
(var skipped {})
|
||||
|
||||
(fn should-skip [typestr]
|
||||
(accumulate [matched false
|
||||
ty (string.gmatch typestr "([^,]+),?%s*")
|
||||
&until matched]
|
||||
(accumulate [blacklisted false
|
||||
_ bl (ipairs blacklist)
|
||||
&until blacklisted]
|
||||
(= ty bl))))
|
||||
|
||||
(fn msg [msg]
|
||||
(print msg)
|
||||
(mp.osd_message (.. "[sbskip] " msg) 4))
|
||||
|
||||
(fn on-chapter-change [_ chapter#]
|
||||
(when (and chapter# (not (. skipped chapter#)))
|
||||
(let [chapter-list (mp.get_property_native :chapter-list)
|
||||
|
@ -17,11 +30,8 @@
|
|||
next (. chapter-list (+ chapter# 2))
|
||||
seg-type (string.match chapter.title "%[SponsorBlock%]: (.*)")]
|
||||
;; when the pattern matches and the type isn't blacklisted...
|
||||
(when (and seg-type (not (accumulate [has false
|
||||
_ type (ipairs blacklist)
|
||||
&until has]
|
||||
(= type seg-type))))
|
||||
(mp.osd_message (.. "[sbskip] skip: " seg-type) 4)
|
||||
(when (and seg-type (should-skip seg-type))
|
||||
(msg (.. "skip: " seg-type))
|
||||
;; add to skipped to not skip chapter again
|
||||
(tset skipped chapter# true)
|
||||
;; set time to start of next chapter or end of video
|
||||
|
|
Loading…
Reference in a new issue