♻️ (TFC/__init__.py): initialize chapters with a default first chapter and adjust chapter indexing
This commit is contained in:
parent
e1977c60b1
commit
67bec7f817
@ -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}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user