Skip to content

Commit c0ce07e

Browse files
committed
Update Schedule model
Schedule model now returns an empty list for segments if there are no segments set on Twitch. Fix typo.
1 parent c48fb59 commit c0ce07e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

twitchio/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ class Schedule:
11311131
Attributes
11321132
-----------
11331133
segments: List[:class:`~twitchio.ScheduleSegment`]
1134-
Segment of a channel's stream schedule.
1134+
List of segments of a channel's stream schedule.
11351135
user: :class:`~twitchio.PartialUser`
11361136
The user of the channel associated to the schedule.
11371137
vacation: :class:`~twitchio.ScheduleVacation`
@@ -1141,7 +1141,7 @@ class Schedule:
11411141
__slots__ = ("segments", "user", "vacation")
11421142

11431143
def __init__(self, http: "TwitchHTTP", data: dict):
1144-
self.segments = [ScheduleSegment(d) for d in data["data"]["segments"]]
1144+
self.segments = [ScheduleSegment(d) for d in data["data"]["segments"]] if data["data"]["segments"] else []
11451145
self.user = PartialUser(http, data["data"]["broadcaster_id"], data["data"]["broadcaster_login"])
11461146
self.vacation = ScheduleVacation(data["data"]["vacation"]) if data["data"]["vacation"] else None
11471147

@@ -1151,7 +1151,7 @@ def __repr__(self):
11511151

11521152
class ScheduleSegment:
11531153
"""
1154-
Represents a segment of a channel's stream schedule
1154+
Represents a list segments of a channel's stream schedule
11551155
11561156
Attributes
11571157
-----------
@@ -1183,7 +1183,7 @@ def __init__(self, data: dict):
11831183
self.is_recurring: bool = data["is_recurring"]
11841184

11851185
def __repr__(self):
1186-
return f"<Segment id={self.id} start_time={self.start_time} end_time={self.end_time} title={self.title} canceled_until={self.canceled_until} category={self.category} is_recurring={self.is_recurring}>"
1186+
return f"<ScheduleSegment id={self.id} start_time={self.start_time} end_time={self.end_time} title={self.title} canceled_until={self.canceled_until} category={self.category} is_recurring={self.is_recurring}>"
11871187

11881188

11891189
class ScheduleCategory:

0 commit comments

Comments
 (0)