Skip to content

Commit 9628522

Browse files
committed
Add is_featured for clips
Add is_featured for clips model and endpoint
1 parent 012f551 commit 9628522

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Master
1313
- New models for the new methods have been added:
1414
- :class:`~twitchio.ChannelFollowerEvent`
1515
- :class:`~twitchio.ChannelFollowingEvent`
16+
- New optional ``is_featured`` query parameter for :func:`~twitchio.PartialUser.fetch_clips`
17+
- New attribute :attr:`~twitchio.Clip.is_featured` for :class:`~twitchio.Clip`
1618

1719
- Bug fixes
1820
- Fix IndexError when getting prefix when empty message is sent in a reply.

twitchio/ext/eventsub/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ def __init__(
252252
self, client: Union[EventSubClient, EventSubWSClient], _data: Union[str, dict], request: Optional[web.Request]
253253
):
254254
# we skip the super init here because reconnect events dont have headers or subscription information
255-
255+
256256
self._client = client
257257
self._raw_data = _data
258258

259259
if isinstance(_data, str):
260260
data: dict = _loads(_data)
261261
else:
262262
data = _data
263-
263+
264264
self.setup(data["payload"])
265265

266266
def setup(self, data: dict):

twitchio/http.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ async def get_clips(
574574
ids: Optional[List[str]] = None,
575575
started_at: Optional[datetime.datetime] = None,
576576
ended_at: Optional[datetime.datetime] = None,
577+
is_featured: Optional[bool] = None,
577578
token: Optional[str] = None,
578579
):
579580
if started_at and started_at.tzinfo is None:
@@ -586,6 +587,7 @@ async def get_clips(
586587
("game_id", game_id),
587588
("started_at", started_at.isoformat() if started_at else None),
588589
("ended_at", ended_at.isoformat() if ended_at else None),
590+
("is_featured", str(is_featured) if is_featured is not None else None),
589591
]
590592
if ids:
591593
q.extend(("id", id) for id in ids)

twitchio/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ class Clip:
293293
vod_offset: Optional[:class:`int`]
294294
The zero-based offset, in seconds, to where the clip starts in the video (VOD) or stream.
295295
This can be None if the parent no longer exists
296+
is_featured: :class:`bool`
297+
Indicates if the clip is featured or not.
296298
"""
297299

298300
__slots__ = (
@@ -310,6 +312,7 @@ class Clip:
310312
"thumbnail_url",
311313
"duration",
312314
"vod_offset",
315+
"is_featured",
313316
)
314317

315318
def __init__(self, http: "TwitchHTTP", data: dict):
@@ -327,6 +330,7 @@ def __init__(self, http: "TwitchHTTP", data: dict):
327330
self.thumbnail_url: str = data["thumbnail_url"]
328331
self.duration: float = data["duration"]
329332
self.vod_offset: Optional[int] = data["vod_offset"]
333+
self.is_featured: bool = data["is_featured"]
330334

331335
def __repr__(self):
332336
return f"<Clip id={self.id} broadcaster={self.broadcaster} creator={self.creator}>"

twitchio/user.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,10 @@ async def create_clip(self, token: str, has_delay=False) -> dict:
335335
return data[0]
336336

337337
async def fetch_clips(
338-
self, started_at: Optional[datetime.datetime] = None, ended_at: Optional[datetime.datetime] = None
338+
self,
339+
started_at: Optional[datetime.datetime] = None,
340+
ended_at: Optional[datetime.datetime] = None,
341+
is_featured: Optional[bool] = None,
339342
) -> List["Clip"]:
340343
"""|coro|
341344
@@ -350,14 +353,17 @@ async def fetch_clips(
350353
ended_at: Optional[:class:`datetime.datetime`]
351354
Ending date/time for returned clips.
352355
If this is specified, started_at also must be specified; otherwise, the time period is ignored.
356+
is_featured: Optional[:class:`bool`]
357+
Optional bool to only return only featured clips or not featured clips.
358+
353359
354360
Returns
355361
--------
356362
List[:class:`twitchio.Clip`]
357363
"""
358364
from .models import Clip
359365

360-
data = await self._http.get_clips(self.id, started_at=started_at, ended_at=ended_at)
366+
data = await self._http.get_clips(self.id, started_at=started_at, ended_at=ended_at, is_featured=is_featured)
361367

362368
return [Clip(self._http, x) for x in data]
363369

0 commit comments

Comments
 (0)