diff --git a/docs/changelog.rst b/docs/changelog.rst index 67c69c02..dd71db47 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,6 +13,8 @@ Master - New models for the new methods have been added: - :class:`~twitchio.ChannelFollowerEvent` - :class:`~twitchio.ChannelFollowingEvent` + - New optional ``is_featured`` query parameter for :func:`~twitchio.PartialUser.fetch_clips` + - New attribute :attr:`~twitchio.Clip.is_featured` for :class:`~twitchio.Clip` - Bug fixes - Fix IndexError when getting prefix when empty message is sent in a reply. diff --git a/twitchio/ext/eventsub/models.py b/twitchio/ext/eventsub/models.py index 5702ba69..8e22334a 100644 --- a/twitchio/ext/eventsub/models.py +++ b/twitchio/ext/eventsub/models.py @@ -252,7 +252,7 @@ def __init__( self, client: Union[EventSubClient, EventSubWSClient], _data: Union[str, dict], request: Optional[web.Request] ): # we skip the super init here because reconnect events dont have headers or subscription information - + self._client = client self._raw_data = _data @@ -260,7 +260,7 @@ def __init__( data: dict = _loads(_data) else: data = _data - + self.setup(data["payload"]) def setup(self, data: dict): diff --git a/twitchio/http.py b/twitchio/http.py index ac7c6ff7..2276af5c 100644 --- a/twitchio/http.py +++ b/twitchio/http.py @@ -574,6 +574,7 @@ async def get_clips( ids: Optional[List[str]] = None, started_at: Optional[datetime.datetime] = None, ended_at: Optional[datetime.datetime] = None, + is_featured: Optional[bool] = None, token: Optional[str] = None, ): if started_at and started_at.tzinfo is None: @@ -586,6 +587,7 @@ async def get_clips( ("game_id", game_id), ("started_at", started_at.isoformat() if started_at else None), ("ended_at", ended_at.isoformat() if ended_at else None), + ("is_featured", str(is_featured) if is_featured is not None else None), ] if ids: q.extend(("id", id) for id in ids) diff --git a/twitchio/models.py b/twitchio/models.py index 4ec79304..033f0ee0 100644 --- a/twitchio/models.py +++ b/twitchio/models.py @@ -293,6 +293,8 @@ class Clip: vod_offset: Optional[:class:`int`] The zero-based offset, in seconds, to where the clip starts in the video (VOD) or stream. This can be None if the parent no longer exists + is_featured: :class:`bool` + Indicates if the clip is featured or not. """ __slots__ = ( @@ -310,6 +312,7 @@ class Clip: "thumbnail_url", "duration", "vod_offset", + "is_featured", ) def __init__(self, http: "TwitchHTTP", data: dict): @@ -327,6 +330,7 @@ def __init__(self, http: "TwitchHTTP", data: dict): self.thumbnail_url: str = data["thumbnail_url"] self.duration: float = data["duration"] self.vod_offset: Optional[int] = data["vod_offset"] + self.is_featured: bool = data["is_featured"] def __repr__(self): return f"" diff --git a/twitchio/user.py b/twitchio/user.py index 4daf4caf..86b39018 100644 --- a/twitchio/user.py +++ b/twitchio/user.py @@ -335,7 +335,10 @@ async def create_clip(self, token: str, has_delay=False) -> dict: return data[0] async def fetch_clips( - self, started_at: Optional[datetime.datetime] = None, ended_at: Optional[datetime.datetime] = None + self, + started_at: Optional[datetime.datetime] = None, + ended_at: Optional[datetime.datetime] = None, + is_featured: Optional[bool] = None, ) -> List["Clip"]: """|coro| @@ -350,6 +353,9 @@ async def fetch_clips( ended_at: Optional[:class:`datetime.datetime`] Ending date/time for returned clips. If this is specified, started_at also must be specified; otherwise, the time period is ignored. + is_featured: Optional[:class:`bool`] + Optional bool to only return only featured clips or not featured clips. + Returns -------- @@ -357,7 +363,7 @@ async def fetch_clips( """ from .models import Clip - data = await self._http.get_clips(self.id, started_at=started_at, ended_at=ended_at) + data = await self._http.get_clips(self.id, started_at=started_at, ended_at=ended_at, is_featured=is_featured) return [Clip(self._http, x) for x in data]