Skip to content

Commit cf3803a

Browse files
committed
Add PartialUser.fetch_followed_streams
Add PartialUser.fetch_followed_streams
1 parent 7fbd3a7 commit cf3803a

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Master
1414
- Added ``tags`` attribute to :class:`~twitchio.Stream`, :class:`~twitchio.ChannelInfo` and :class:`~twitchio.SearchUser`
1515
- Added :func:`~twitchio.PartialUser.fetch_shield_mode_status`
1616
- Added :func:`~twitchio.PartialUser.update_shield_mode_status`
17+
- Added :func:`~twitchio.PartialUser.fetch_followed_streams`
1718

1819
- Bug fixes
1920
- Fix :func:`~twitchio.PartialUser.fetch_bits_leaderboard` not handling ``started_at`` and :class:`~twitchio.BitsLeaderboard` not correctly parsing

twitchio/http.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,3 +1119,6 @@ async def put_shield_mode_status(self, token: str, broadcaster_id: str, moderato
11191119
q = [("broadcaster_id", broadcaster_id), ("moderator_id", moderator_id)]
11201120
body = {"is_active": is_active}
11211121
return await self.request(Route("PUT", "moderation/shield_mode", query=q, body=body, token=token))
1122+
1123+
async def get_followed_streams(self, broadcaster_id: str, token: str):
1124+
return await self.request(Route("GET", "streams/followed", query=[("user_id", broadcaster_id)], token=token))

twitchio/user.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,27 @@ async def update_shield_mode_status(self, token: str, moderator_id: int, is_acti
15531553

15541554
return ShieldStatus(self._http, data[0])
15551555

1556+
async def fetch_followed_streams(self, token: str):
1557+
"""|coro|
1558+
1559+
Fetches a list of broadcasters that the user follows and that are streaming live.
1560+
1561+
Parameters
1562+
-----------
1563+
token: :class:`str`
1564+
An oauth user token with the ``user:read:follows`` scope.
1565+
1566+
Returns
1567+
--------
1568+
List[:class:`twitchio.Stream`]
1569+
"""
1570+
1571+
data = await self._http.get_followed_streams(broadcaster_id=str(self.id), token=token)
1572+
1573+
from .models import Stream
1574+
1575+
return [Stream(self._http, x) for x in data]
1576+
15561577

15571578
class BitLeaderboardUser(PartialUser):
15581579

0 commit comments

Comments
 (0)