From 67bec7f817698d8ad747729a97468040cd1ee8c4 Mon Sep 17 00:00:00 2001 From: "Sp4rk.y" Date: Wed, 31 Jul 2024 12:42:37 -0600 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(TFC/=5F=5Finit=5F=5F.py):?= =?UTF-8?q?=20initialize=20chapters=20with=20a=20default=20first=20chapter?= =?UTF-8?q?=20and=20adjust=20chapter=20indexing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TFC/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/TFC/__init__.py b/TFC/__init__.py index 7a7b878..9e56fe5 100644 --- a/TFC/__init__.py +++ b/TFC/__init__.py @@ -259,11 +259,14 @@ class TFC(Service): # Sort the cuepoints sorted_cuepoints = sorted(cuepoints, key=lambda x: datetime.strptime(x, "%H:%M:%S.%f")) - chapters = [] - for i, cuepoint in enumerate(sorted_cuepoints): + chapters = [ + Chapter(name="Chapter 1", timestamp="00:00:00.000") + ] + + for i, cuepoint in enumerate(sorted_cuepoints, start=2): try: timestamp = datetime.strptime(cuepoint, "%H:%M:%S.%f").time() - chapters.append(Chapter(name=f"Chapter {i + 1}", timestamp=timestamp.strftime("%H:%M:%S.%f")[:-3])) + chapters.append(Chapter(name=f"Chapter {i}", timestamp=timestamp.strftime("%H:%M:%S.%f")[:-3])) except ValueError: self.log.warning(f"Invalid cuepoint format: {cuepoint}")