Skip to content

Commit

Permalink
Add check for segment structure
Browse files Browse the repository at this point in the history
  • Loading branch information
bertybuttface committed Jan 28, 2024
1 parent c71660b commit 13ba850
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/iSponsorBlockTV/api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def process_segments(response):
if "segments" not in response:
return [], True

for seg in response["segments"]:
if not isinstance(seg, dict) or "segment" not in seg or not isinstance(seg["segment"], list):
raise TypeError("Invalid segment structure")

# Sort segments by their start time
sorted_segments = sorted(response["segments"], key=lambda x: x["segment"][0])

Expand Down

0 comments on commit 13ba850

Please sign in to comment.