From ebaa1c216bf87c1f537ad49f4a93b03355e8606f Mon Sep 17 00:00:00 2001 From: EvieePy <29671945+EvieePy@users.noreply.github.com> Date: Sun, 5 Jan 2025 12:05:01 +1000 Subject: [PATCH] Add Video and Stream eq --- twitchio/models/streams.py | 6 ++++++ twitchio/models/videos.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/twitchio/models/streams.py b/twitchio/models/streams.py index d490ada2..e618ce6e 100644 --- a/twitchio/models/streams.py +++ b/twitchio/models/streams.py @@ -135,6 +135,12 @@ async def fetch_game(self) -> Game | None: payload: GamesResponse = await self._http.get_games(ids=[self.game_id]) return Game(payload["data"][0], http=self._http) if payload["data"] else None + def __eq__(self, other: object) -> bool: + if not isinstance(other, Stream): + return NotImplemented + + return self.id == other.id and self.started_at == other.started_at + class StreamMarker: """Represents a stream marker. diff --git a/twitchio/models/videos.py b/twitchio/models/videos.py index a58a0c87..0563150a 100644 --- a/twitchio/models/videos.py +++ b/twitchio/models/videos.py @@ -117,3 +117,9 @@ async def delete(self, token_for: str) -> None: A user oauth token with the ``channel:manage:videos`` scope. """ await self._http.delete_videos(ids=[self.id], token_for=token_for) + + def __eq__(self, other: object) -> bool: + if not isinstance(other, Video): + return NotImplemented + + return self.id == other.id