thecactusvert / mpv-sponsorblock Goto Github PK
View Code? Open in Web Editor NEWMPV plugin that allow you to skip sponsors while watching YouTube videos
License: MIT License
MPV plugin that allow you to skip sponsors while watching YouTube videos
License: MIT License
It would be nice to have a binary release for the shared library so that a user may only have to download and place it in the right location besides the config.
I can write a github actions workflow to automate this if you are interested.
When playing some videos (mostly Chinese), the plugin gives the following error:
[ERROR mpv_sponsorblock::sponsorblock] Failed to get segments: the SponsorBlock API returned invalid data..
When playing English videos, is is usually fine.
Example: https://www.youtube.com/watch?v=hSbj3jpQxgc
It detects the segments and shows them in the timeline, but doesn't actually skip anything, even though I set it to do so in the config. I placed all the files in the right places and everything works fine with the command line version. I also looked through the log output (debug level) but didn't seem to find anything useful.
Using v2.1.0 on Arch Linux (x86-64) with mpv v0.38.0.
When playing only the audio of a Youtube video that has ads, mpv-sponsorblock
sometimes enters a skip-loop after skipping the ad. The loop can be exited by manually seeking forward a second. Playing only the audio part is sometimes useful to save network bandwidth/skip video decoding if the video part is not relevant.
This does not happen 100% of the time. Currently, I've only been able to reproduce it when using a Bluetooth headset (I am using PipeWire audio output) which I suspect might have some impact on the time-pos
property reported by mpv. Also, I've found that for some videos it depends on the audio format and/or quality (e.g. using --ytdl-format=worstaudio
would not cause the loop).
To reproduce (note that --start=348
will skip to the position 2 seconds before the ad):
RUST_LOG=trace mpv --ytdl-format=bestaudio --no-resume-playback --start=348 'https://www.youtube.com/watch?v=T1KXeTd30KI'
[2024-04-30T09:36:05Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
statusline: A: 00:07:17 / 00:11:52 (61%) Cache: 274s/11MB
[-------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------][2024-04-30T09:36:05Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:05Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:05Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:05Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:05Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:05Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:05Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:05Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:05Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:05Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:05Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:05Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:06Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:06Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z INFO mpv_sponsorblock::client] Skipped segment [sponsor] 350.621 - 437.6
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
[2024-04-30T09:36:07Z TRACE mpv_sponsorblock::client] Received property-change event [time-pos]
...
After some debugging, I've found that the time-pos
reported by mpv after skipping an ad would fall slightly before the end of the segment that was skipped (even after the 0.1s adjustment) and the segment therefore would be matched and skipped, causing an endless loop.
Please let me know if more information is needed.
Note: Without this extension mpv plays youtube video without any trouble!
$ cat sponsorblock.toml
# Server address
server_address = "https://sponsor.ajay.app"
# Categories: sponsor, selfpromo, interaction, poi_highlight, intro, outro, preview, music_offtopic, filler, exclusive_access
categories = ["sponsor", "selfpromo", "interaction", "poi_highlight", "intro", "outro", "preview", "music_offtopic", "exclusive_access"]
# Action types: skip, mute, poi, full
action_types = ["skip"]
# Get segments for a video with extra privacy
privacy_api = false
# Third party YouTube domains like Piped, Invidious or CloudTube
domains = ["piped.kavin.rocks", "invidious.kavin.rocks"]
# Use OSD when a segment is skipped or muted
skip_notice = false
$ mpv https://www.youtube.com/watch?v=6YF0XNMpyoM
(+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
File tags:
Uploader: Jonathan Antoine
Channel_URL: https://www.youtube.com/channel/UC1aQpzmR_Nf0C7ElGiySLQg
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pipewire] 48000Hz stereo 2ch floatp
AV: 00:00:31 / 00:05:37 (9%) A-V: 0.000 Cache: 305s/12MB
$ mpv https://www.youtube.com/watch?v=6YF0XNMpyoM
(+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
File tags:
Uploader: Jonathan Antoine
Channel_URL: https://www.youtube.com/channel/UC1aQpzmR_Nf0C7ElGiySLQg
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pipewire] 48000Hz stereo 2ch floatp
VO: [gpu] 1920x1080 yuv420p
AV: 00:00:03 / 00:05:37 (1%) A-V: 0.000 Cache: 63s/28MB
Could the config be documented better? Eg. what is the "poi" or "full" action in action_types
?
for windows?
The latest release no longer builds with latest nightly toolchain.
While testing my setup on this video, the following error is printed to the terminal:
[2023-07-12T21:47:12Z ERROR mpv_sponsorblock::client::worker] Failed to get segments: error decoding response body: missing field `hash` at line 1 column 675
I also tested this on other videos, and they gave the same error.
Once a video is loaded and the script is active, it is impossible to seek backwards to the skipped segment. A keybind toggle to turn the script on and off live would be great. Same way mpv_sponsorblock_minimal does it. It uses the b key, which I'm used to by now.
This project supports segment submission and voting. Expecting the same here.
It will be great if you can add an open source license, so that the community can make full use of it and legally link it to mpv.
Using 2.0.0 on Arch Linux (x86-64) with mpv v0.37.0.
To reproduce (assuming mpv-sponsorblock is installed; use bash for the ANSI-C quoting):
mkdir test
cd test
touch $'foo\xf0.mp3'
RUST_LOG=trace mpv --load-scripts=yes --no-resume-playback *.mp3 'https://www.youtube.com/watch?v=aqz-KE-bpKQ'
I get:
[2024-03-01T10:18:18Z DEBUG mpv_sponsorblock] Starting plugin SponsorBlock [sponsorblock]!
[2024-03-01T10:18:18Z TRACE mpv_sponsorblock::client] Received start-file event
cplayer: Playing: foo.mp3
Segmentation fault (core dumped)
Disabling scripts (I only have mpv-sponsorblock installed):
RUST_LOG=trace mpv --load-scripts=no --no-resume-playback *.mp3 'https://www.youtube.com/watch?v=aqz-KE-bpKQ'
I get:
cplayer: Playing: foo.mp3
cplayer: Failed to recognize file format.
cplayer: Playing: https://www.youtube.com/watch?v=aqz-KE-bpKQ
I am reporting it here (and not in mpv's bugtracker) since it only occurs when mpv-sponsorblock is installed and enabled. If it is mpv's bug in handling script crashes, please let me know and I'll report it there.
Hopefully this is reproducible, please let me know if you need more details.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.