Skip to content

Commit f55ea02

Browse files
committed
Add documentation for Clip.video_id attr and fix fetch_video method
1 parent 758b5a9 commit f55ea02

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

twitchio/models/clips.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ class Clip:
6565
creator: twitchio.PartialUser
6666
The user who created the clip.
6767
video_id: str
68-
The ID of the video the clip is sourced from.
68+
The ID of the video the clip is sourced from. This could be an empty :class:`str` if the video associated with the Clip
69+
is not available. This could be due to either the broadcaster or Twitch removing the video or because the video has
70+
not yet been made available (this can take a few minutes after Clip creation to occur).
6971
game_id: str
7072
The ID of the game that was being played when the clip was created.
7173
language: str
@@ -143,15 +145,23 @@ async def fetch_video(self) -> Video | None:
143145
144146
Fetches the :class:`~twitchio.Video` associated with this clip, if it can be found.
145147
148+
.. note::
149+
150+
If :attr:`.video_id` is an empty :class:`str` this method will return ``None``. This could be due to either the
151+
broadcaster or Twitch removing the video or because the video has not yet been made available
152+
(this can take a few minutes after Clip creation to occur).
153+
146154
Returns
147155
-------
148156
Video
149157
The video associated with this Clip.
150158
None
151-
The video was not found.
159+
The video was not found or is not yet available.
152160
"""
153-
data: list[Video] = await self._http.get_videos(ids=[self.video_id], period="all", sort="time", type="all", first=1)
161+
if not self.video_id:
162+
return None
154163

164+
data: list[Video] = await self._http.get_videos(ids=[self.video_id], period="all", sort="time", type="all", first=1)
155165
return data[0] if data else None
156166

157167

0 commit comments

Comments
 (0)