Skip to content

Commit 4ad023d

Browse files
committed
Add Optional User.fetch_clips args
Add Optional started_at and ended_at arguments for PartialUser.fetch_clips
1 parent 59b650a commit 4ad023d

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

docs/changelog.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
:orphan:
22

33

4+
Master
5+
======
6+
- TwitchIO
7+
- Additions
8+
- Added optional ``started_at`` and ``ended_at`` arguments to :func:`~twitchio.PartialUser.fetch_clips`
9+
410
2.5.0
511
======
612
- TwitchIO

twitchio/http.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@ async def get_clips(
551551
ended_at: Optional[datetime.datetime] = None,
552552
token: Optional[str] = None,
553553
):
554+
if started_at and started_at.tzinfo is None:
555+
started_at = started_at.replace(tzinfo=datetime.timezone.utc)
556+
if ended_at and ended_at.tzinfo is None:
557+
ended_at = ended_at.replace(tzinfo=datetime.timezone.utc)
558+
554559
q = [
555560
("broadcaster_id", broadcaster_id),
556561
("game_id", game_id),

twitchio/user.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,19 +322,30 @@ async def create_clip(self, token: str, has_delay=False) -> dict:
322322
data = await self._http.post_create_clip(token, self.id, has_delay)
323323
return data[0]
324324

325-
async def fetch_clips(self) -> List["Clip"]:
325+
async def fetch_clips(
326+
self, started_at: Optional[datetime.datetime] = None, ended_at: Optional[datetime.datetime] = None
327+
) -> List["Clip"]:
326328
"""|coro|
327329
328330
Fetches clips from the api. This will only return clips from the specified user.
329331
Use :class:`Client.fetch_clips` to fetch clips by id
330332
333+
Parameters
334+
-----------
335+
started_at: Optional[:class:`datetime.datetime`]
336+
Starting date/time for returned clips.
337+
If this is specified, ended_at also should be specified; otherwise, the ended_at date/time will be 1 week after the started_at value.
338+
ended_at: Optional[:class:`datetime.datetime`]
339+
Ending date/time for returned clips.
340+
If this is specified, started_at also must be specified; otherwise, the time period is ignored.
341+
331342
Returns
332343
--------
333344
List[:class:`twitchio.Clip`]
334345
"""
335346
from .models import Clip
336347

337-
data = await self._http.get_clips(self.id)
348+
data = await self._http.get_clips(self.id, started_at=started_at, ended_at=ended_at)
338349

339350
return [Clip(self._http, x) for x in data]
340351

0 commit comments

Comments
 (0)