Skip to content

Commit b50351f

Browse files
committed
Add new modify_stream / channel params
Add new modify_stream / channel params
1 parent 011b1d5 commit b50351f

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

twitchio/client.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,8 @@ async def fetch_global_chat_badges(self):
819819
820820
Fetches Twitch's list of chat badges, which users may use in any channel's chat room.
821821
822-
Returns:
822+
Returns
823+
--------
823824
List[:class:`twitchio.ChatBadge`]
824825
"""
825826

@@ -837,10 +838,10 @@ async def fetch_content_classification_labels(self, locale: Optional[str] = None
837838
Locale for the Content Classification Labels.
838839
You may specify a maximum of 1 locale. Default: “en-US”
839840
840-
Returns:
841+
Returns
842+
--------
841843
List[:class:`twitchio.ContentClassificationLabel`]
842844
"""
843-
844845
locale = "en-US" if locale is None else locale
845846
data = await self._http.get_content_classification_labels(locale)
846847
return [models.ContentClassificationLabel(x) for x in data]

twitchio/http.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -717,15 +717,30 @@ async def get_channels_new(self, broadcaster_ids: List[int], token: Optional[str
717717
return await self.request(Route("GET", "channels", query=q, token=token))
718718

719719
async def patch_channel(
720-
self, token: str, broadcaster_id: str, game_id: str = None, language: str = None, title: str = None
720+
self,
721+
token: str,
722+
broadcaster_id: str,
723+
game_id: str = None,
724+
language: str = None,
725+
title: str = None,
726+
content_classification_labels: List[Dict[str, Union[str, bool]]] = None,
727+
is_branded_content: bool = None,
721728
):
722-
assert any((game_id, language, title))
729+
assert any((game_id, language, title, content_classification_labels, is_branded_content))
723730
body = {
724731
k: v
725-
for k, v in {"game_id": game_id, "broadcaster_language": language, "title": title}.items()
732+
for k, v in {
733+
"game_id": game_id,
734+
"broadcaster_language": language,
735+
"title": title,
736+
"is_branded_content": is_branded_content,
737+
}.items()
726738
if v is not None
727739
}
728740

741+
if content_classification_labels is not None:
742+
body["content_classification_labels"] = content_classification_labels
743+
729744
return await self.request(
730745
Route("PATCH", "channels", query=[("broadcaster_id", broadcaster_id)], body=body, token=token)
731746
)

twitchio/user.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import datetime
2626
import time
27-
from typing import TYPE_CHECKING, List, Optional, Union, Tuple
27+
from typing import TYPE_CHECKING, List, Optional, Union, Tuple, Dict
2828

2929
from .enums import BroadcasterTypeEnum, UserTypeEnum
3030
from .errors import HTTPException, Unauthorized
@@ -878,7 +878,15 @@ async def create_prediction(
878878
)
879879
return Prediction(self._http, data[0])
880880

881-
async def modify_stream(self, token: str, game_id: int = None, language: str = None, title: str = None):
881+
async def modify_stream(
882+
self,
883+
token: str,
884+
game_id: int = None,
885+
language: str = None,
886+
title: str = None,
887+
content_classification_labels: List[Dict[str, Union[str, bool]]] = None,
888+
is_branded_content: bool = None,
889+
):
882890
"""|coro|
883891
884892
Modify stream information
@@ -893,6 +901,19 @@ async def modify_stream(self, token: str, game_id: int = None, language: str = N
893901
Optional language of the channel. A language value must be either the ISO 639-1 two-letter code for a supported stream language or “other”.
894902
title: :class:`str`
895903
Optional title of the stream.
904+
content_classification_labels: List[Dict[:class:`str`, Union[:class:`str`, :class:`bool`]]]
905+
List of labels that should be set as the Channel's CCLs.
906+
is_branded_content: :class:`bool`
907+
Boolean flag indicating if the channel has branded content.
908+
909+
.. note::
910+
911+
Example of a content classification labels
912+
.. code:: py
913+
914+
ccl = [{"id": "Gambling", "is_enabled": False}, {"id": "DrugsIntoxication", "is_enabled": False}]
915+
await my_partial_user.modify_stream(token="abcd", content_classification_labels=ccl)
916+
896917
"""
897918
if game_id is not None:
898919
game_id = str(game_id)
@@ -902,6 +923,8 @@ async def modify_stream(self, token: str, game_id: int = None, language: str = N
902923
game_id=game_id,
903924
language=language,
904925
title=title,
926+
content_classification_labels=content_classification_labels,
927+
is_branded_content=is_branded_content,
905928
)
906929

907930
async def fetch_schedule(

0 commit comments

Comments
 (0)