siku2 / script.service.sponsorblock

Kodi add-on for SponsorBlock
MIT License
126 stars 15 forks source link

Pausing/seeking through the video will mess up the skips #23

Closed matejdro closed 2 years ago

matejdro commented 3 years ago

Steps to reproduce:

  1. Watch a video with sponsors
  2. Before sponsor, skip ahead 10 seconds
  3. Wait until the sponsor segment

BUG: Sponsor will be skipped 10 seconds late

My guess is that SponsorBlock works by setting up the timer when the video starts and then triggers skips purely on that timer?

From what I see, Kodi offers callbacks on various player events, so this shouldn't bee too hard to fix: https://codedocs.xyz/AlwinEsch/kodi/group__python___player_c_b.html#ga68978e1dd9c1c1fbd562ff2feb5fb6a7

If you are too busy, I could try my hand at PR for this at some point.

siku2 commented 3 years ago

Hmm, I think we're gonna need some logs to debug this one. You're correct about it being based on a timer, but the code is already supposed to handle all kinds of events. In hindsight I should've gone with polling, but I didn't know how clunky Kodi's API is back then. If you're curious, the relevant code can be found here: https://github.com/siku2/script.service.sponsorblock/blob/master/resources/lib/utils/checkpoint_listener.py

matejdro commented 3 years ago

Okay, here are the logs: kodi.log

Logs contain me playing same video twice, once without skipping and once with skipping:

16:37:12 - I begin playing video for the first time 16:37:45 - Sponsor is skipped normally, ~33 seconds into the video

16:37:56 - I start playing video for the second time 16:37:58 - I skip 10 seconds ahead of the video 16:38:19 - Sponsor skip should happen at around that time (33 seconds into the video minus skipped 10 seconds) 16:38:29 - Sponsor is skipped ~33 seconds after playback started. However, since I skipped around the video, it was 10 seconds late.

die2gether commented 3 years ago

Seems like I'm having the same issue, or something very similar to this, however skips triggered by the addon itself also cause problems with skipping the next segment on the same video.

In case of that happening, the debug log always shows the message "overshot checkpoint by X seconds" and the unwanted segment is played in full length.

Can be seen here for example:

2021-06-08 09:50:01.141 T:9974 DEBUG : [script.service.sponsorblock] utils.checkpoint_listener: seek time expired 2021-06-08 09:50:01.141 T:9974 DEBUG : [script.service.sponsorblock] utils.checkpoint_listener: woke up: reached checkpoint 2021-06-08 09:50:01.141 T:9974 WARNING : [script.service.sponsorblock] utils.checkpoint_listener: overshot checkpoint 571.9825 by 2.788557128906291 second(s), ignoring