From a160df06a5929200c2d5b4cba2224bc56b8f6f05 Mon Sep 17 00:00:00 2001
From: apricotjam4 <apricotjam4@cock.li>
Date: Mon, 14 Apr 2025 16:51:53 +0100
Subject: [PATCH] ALL4: don't extract pre-roll (0:00:00) ads as a chapter
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

so we don't get dupes if the intro chapter is at 0ms
core still sets a chapter at 0:00:00 no matter what, so it's fineā„¢
---
 services/ALL4/__init__.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/services/ALL4/__init__.py b/services/ALL4/__init__.py
index b22fd21..5ee1e4e 100644
--- a/services/ALL4/__init__.py
+++ b/services/ALL4/__init__.py
@@ -267,12 +267,14 @@ class ALL4(Service):
     def get_chapters(self, title: Union[Movie, Episode]) -> list[Chapter]:
         track = title.tracks.videos[0]
 
-        chapters = [
-            Chapter(
-                timestamp=datetime.fromtimestamp((ms / 1000), tz=timezone.utc).strftime("%H:%M:%S.%f")[:-3],
-            )
-            for i, ms in enumerate(x["breakOffset"] for x in track.data["adverts"]["breaks"])
-        ]
+        chapters = []
+
+        for x in track.data["adverts"]["breaks"]:
+            ms = x.get("breakOffset")
+            if ms != 0:
+                chapters.append(Chapter(
+                    timestamp=datetime.fromtimestamp((ms / 1000), tz=timezone.utc).strftime("%H:%M:%S.%f")[:-3],
+                ))
 
         if intro_data := track.data.get("skipIntro"):
             chapters.append(