Skip to content

Commit 78098b0

Browse files
committed
fix #365
1 parent fd5fde6 commit 78098b0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

twitchio/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import logging
2929
import traceback
3030
import sys
31-
from typing import Union, Callable, List, Optional, Tuple, Any, Coroutine, Dict
31+
from typing import Union, Callable, List, Optional, Tuple, Any, Coroutine, Dict, Literal
3232

3333
from twitchio.errors import HTTPException, AuthenticationError
3434
from . import models
@@ -648,6 +648,7 @@ async def fetch_streams(
648648
user_logins: Optional[List[str]] = None,
649649
languages: Optional[List[str]] = None,
650650
token: Optional[str] = None,
651+
type: Literal["all", "live"] = "all"
651652
):
652653
"""|coro|
653654
@@ -665,19 +666,21 @@ async def fetch_streams(
665666
language for the stream(s). ISO 639-1 or two letter code for supported stream language
666667
token: Optional[:class:`str`]
667668
An optional OAuth token to use instead of the bot OAuth token
669+
type: Literal["all", "live"]
670+
One of ``"all"`` or ``"live"``. Defaults to ``"all"``. Specifies what type of stream to fetch.
668671
669672
Returns
670673
--------
671674
List[:class:`twitchio.Stream`]
672675
"""
673676
from .models import Stream
674677

675-
assert user_ids or game_ids or user_logins
676678
data = await self._http.get_streams(
677679
game_ids=game_ids,
678680
user_ids=user_ids,
679681
user_logins=user_logins,
680682
languages=languages,
683+
type_=type,
681684
token=token,
682685
)
683686
return [Stream(self._http, x) for x in data]

twitchio/http.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import copy
2727
import datetime
2828
import logging
29-
from typing import TYPE_CHECKING, Union, List, Tuple, Any, Dict, Optional
29+
from typing import TYPE_CHECKING, Union, List, Tuple, Any, Dict, Optional, Literal
3030

3131
import aiohttp
3232
from yarl import URL
@@ -676,9 +676,10 @@ async def get_streams(
676676
user_ids: Optional[List[int]] = None,
677677
user_logins: Optional[List[str]] = None,
678678
languages: Optional[List[str]] = None,
679+
type_: Literal["all", "live"] = "all",
679680
token: Optional[str] = None,
680681
):
681-
q = []
682+
q = [("type", type_)]
682683
if game_ids:
683684
q.extend(("game_id", str(g)) for g in game_ids)
684685
if user_ids:

0 commit comments

Comments
 (0)