]> jfr.im git - yt-dlp.git/commitdiff
[SponsorBlock] Relax duration check for large segments
authorpukkandan <redacted>
Tue, 18 Oct 2022 17:49:25 +0000 (23:19 +0530)
committerpukkandan <redacted>
Tue, 18 Oct 2022 18:06:59 +0000 (23:36 +0530)
yt_dlp/postprocessor/sponsorblock.py

index bb15eb7096ff58097cdd722d99f18e3c766199e3..188eb059aaad8a52be9fbeb681283819c24a6031 100644 (file)
@@ -64,7 +64,8 @@ def duration_filter(s):
             if duration and duration - start_end[1] <= 1:
                 start_end[1] = duration
             # SponsorBlock duration may be absent or it may deviate from the real one.
-            return s['videoDuration'] == 0 or not duration or abs(duration - s['videoDuration']) <= 1
+            diff = abs(duration - s['videoDuration']) if s['videoDuration'] else 0
+            return diff < 1 or (diff < 5 and diff / (start_end[1] - start_end[0]) < 0.05)
 
         duration_match = [s for s in segments if duration_filter(s)]
         if len(duration_match) != len(segments):