Skip to content

Commit fba82bc

Browse files
committed
Add new tag attribute
Add tag attribute to SearchUser, ChannelInfo and Stream models Update docstrings
1 parent f9d6f14 commit fba82bc

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Master
1111
- Added ``speed`` install flag (``pip install twitchio[speed]``) to install all available speedups
1212
- Added :attr:`~twitchio.Game.igdb_id` to :class:`~twitchio.Game`
1313
- Added ``igdb_ids`` argument to :func:`~twitchio.Client.fetch_games`
14+
- Added ``tags`` attribute to :class:`~twitchio.Stream`, :class:`~twitchio.ChannelInfo` and :class:`~twitchio.SearchUser`
1415

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

twitchio/models.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,15 @@ class Stream:
10211021
Thumbnail URL of the stream.
10221022
tag_ids: List[:class:`str`]
10231023
Tag IDs that apply to the stream.
1024+
1025+
.. warning::
1026+
1027+
This field will be deprecated by twitch in 2023.
1028+
10241029
is_mature: :class:`bool`
10251030
Indicates whether the stream is intended for mature audience.
1031+
tags: List[:class:`str`]
1032+
The tags applied to the channel.
10261033
"""
10271034

10281035
__slots__ = (
@@ -1038,6 +1045,7 @@ class Stream:
10381045
"thumbnail_url",
10391046
"tag_ids",
10401047
"is_mature",
1048+
"tags",
10411049
)
10421050

10431051
def __init__(self, http: "TwitchHTTP", data: dict):
@@ -1053,6 +1061,7 @@ def __init__(self, http: "TwitchHTTP", data: dict):
10531061
self.thumbnail_url: str = data["thumbnail_url"]
10541062
self.tag_ids: List[str] = data["tag_ids"] or []
10551063
self.is_mature: bool = data["is_mature"]
1064+
self.tags: List[str] = data["tags"]
10561065

10571066
def __repr__(self):
10581067
return f"<Stream id={self.id} user={self.user} title={self.title} started_at={self.started_at}>"
@@ -1077,9 +1086,11 @@ class ChannelInfo:
10771086
delay: :class:`int`
10781087
Stream delay in seconds.
10791088
This defaults to 0 if the broadcaster_id does not match the user access token.
1089+
tags: List[:class:`str`]
1090+
The tags applied to the channel.
10801091
"""
10811092

1082-
__slots__ = ("user", "game_id", "game_name", "title", "language", "delay")
1093+
__slots__ = ("user", "game_id", "game_name", "title", "language", "delay", "tags")
10831094

10841095
def __init__(self, http: "TwitchHTTP", data: dict):
10851096
self.user = PartialUser(http, data["broadcaster_id"], data["broadcaster_name"])
@@ -1088,6 +1099,7 @@ def __init__(self, http: "TwitchHTTP", data: dict):
10881099
self.title: str = data["title"]
10891100
self.language: str = data["broadcaster_language"]
10901101
self.delay: int = data["delay"]
1102+
self.tags: List[str] = data["tags"]
10911103

10921104
def __repr__(self):
10931105
return f"<ChannelInfo user={self.user} game_id={self.game_id} game_name={self.game_name} title={self.title} language={self.language} delay={self.delay}>"

twitchio/user.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,8 +1550,52 @@ def __repr__(self):
15501550

15511551

15521552
class SearchUser(PartialUser):
1553+
"""
1554+
Represents a User that has been searched for.
1555+
1556+
Attributes
1557+
----------
1558+
id: :class:`int`
1559+
The ID of the user.
1560+
name: :class:`str`
1561+
The name of the user.
1562+
display_name: :class:`str`
1563+
The broadcaster's display name.
1564+
game_id: :class:`str`
1565+
The ID of the game that the broadcaster is playing or last played.
1566+
title: :class:`str`
1567+
The stream's title. Is an empty string if the broadcaster didn't set it.
1568+
thumbnail_url :class:`str`
1569+
A URL to a thumbnail of the broadcaster's profile image.
1570+
language :class:`str`
1571+
The ISO 639-1 two-letter language code of the language used by the broadcaster. For example, en for English.
1572+
live: :class:`bool`
1573+
A Boolean value that determines whether the broadcaster is streaming live. Is true if the broadcaster is streaming live; otherwise, false.
1574+
started_at: :class:`datetime.datetime`
1575+
The UTC date and time of when the broadcaster started streaming.
1576+
tag_ids: List[:class:`str`]
1577+
Tag IDs that apply to the stream.
1578+
1579+
.. warning::
1580+
1581+
This field will be deprecated by twitch in 2023.
1582+
1583+
tags: List[:class:`str`]
1584+
The tags applied to the channel.
1585+
"""
15531586

1554-
__slots__ = "game_id", "name", "display_name", "language", "title", "thumbnail_url", "live", "started_at", "tag_ids"
1587+
__slots__ = (
1588+
"game_id",
1589+
"name",
1590+
"display_name",
1591+
"language",
1592+
"title",
1593+
"thumbnail_url",
1594+
"live",
1595+
"started_at",
1596+
"tag_ids",
1597+
"tags",
1598+
)
15551599

15561600
def __init__(self, http: "TwitchHTTP", data: dict):
15571601
self._http = http
@@ -1565,6 +1609,7 @@ def __init__(self, http: "TwitchHTTP", data: dict):
15651609
self.live: bool = data["is_live"]
15661610
self.started_at = datetime.datetime.strptime(data["started_at"], "%Y-%m-%dT%H:%M:%SZ") if self.live else None
15671611
self.tag_ids: List[str] = data["tag_ids"]
1612+
self.tags: List[str] = data["tags"]
15681613

15691614

15701615
class User(PartialUser):

0 commit comments

Comments
 (0)