po5 / mpv_sponsorblock

mpv script to skip sponsored segments of YouTube videos
GNU General Public License v3.0
549 stars 29 forks source link

New Category - poi_highlight #42

Open Obegg opened 3 years ago

Obegg commented 3 years ago

https://github.com/ajayyy/SponsorBlock/wiki/Types#category

image

poi_highlight

Video with the new category: https://www.youtube.com/watch?v=zF2KF-SVIXc

How can I use it on MPV?

I tried to add "poi_highlight" to "skip categories", it does fetch that, but it doesn't skip TO IT, since the script only skips FROM IT. This one is tricky to use since the start and end times are equal, so somehow the script will need to skip to that point (highlight) from the start of the video.

po5 commented 3 years ago

Did notice the new feature while using the browser extension and not sure how to implement this. I think just a chapter marker is fine, letting you use your mpv seeking bindings to jump to that chapter. Just need to check if it already works with the current code.

Obegg commented 3 years ago

Did notice the new feature while using the browser extension and not sure how to implement this. I think just a chapter marker is fine, letting you use your mpv seeking bindings to jump to that chapter. Just need to check if it already works with the current code.

I don't think that "chapter marker" is enough for this one. The whole point of "highlight" is that the VIDEO WILL START FROM that chapter. Meaning the script will need to identify the "highlight" and SKIP TO IT accordingly.

pukkandan commented 2 years ago

There will always only be atmost one poi_highlight per video, so the script could mark 0 to highlight as a chapter and skip it. The feature should be opt-in though and should not be enabled by default imo

alopatindev commented 12 months ago

Dirty workaround for anyone interested:

diff --git a/sponsorblock.lua b/sponsorblock.lua
index 96bfb24..efe86df 100644
--- a/sponsorblock.lua
+++ b/sponsorblock.lua
@@ -108,7 +108,7 @@ local fade_timer = nil
 local fade_dir = nil
 local volume_before = mp.get_property_number("volume")
 local categories = {}
-local all_categories = {"sponsor", "intro", "outro", "interaction", "selfpromo", "preview", "music_offtopic", "filler"}
+local all_categories = {"sponsor", "intro", "outro", "interaction", "selfpromo", "preview", "music_offtopic", "filler", "poi_highlight"}
 local chapter_cache = {}

 for category in string.gmatch(options.skip_categories, "([^,]+)") do
@@ -182,7 +182,7 @@ function process(uuid, t, new_ranges)
         end
     end
     category = string.match(t, "[^,]+$")
-    if categories[category] and end_time - start_time >= options.min_duration then
+    if categories[category] and (end_time - start_time >= options.min_duration or category == 'poi_highlight') then
         new_ranges[uuid] = {
             start_time = start_time,
             end_time = end_time,
@@ -282,6 +282,10 @@ function skip_ads(name, pos)
     if pos == nil then return end
     local sponsor_ahead = false
     for uuid, t in pairs(ranges) do
+        if t.category == "poi_highlight" and not t.skipped then
+            t.skipped = true
+            mp.set_property("time-pos", t.end_time)
+        end
         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
             if options.fast_forward == uuid then return end
             if options.fast_forward == false then
# ~/.config/mpv/script-opts/sponsorblock.conf
skip_categories=sponsor,intro,outro,interaction,selfpromo,preview,music_offtopic,filler,poi_highlight
categories=sponsor,intro,outro,interaction,selfpromo,filler,preview,music_offtopic,poi_highlight
Obegg commented 12 months ago

It doesn't seem like a "workaround", it looks like a solution, will you be able to send a PR for this?