Skip to content

Commit ade540c

Browse files
committed
add undocumented platform parameters for streams.get_all
1 parent 2978982 commit ade540c

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

resources/lib/twitch/api/parameters.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ class StreamType(_Parameter):
7272
_valid = [LIVE, PLAYLIST, ALL]
7373

7474

75+
class Platform(_Parameter):
76+
XBOX_ONE = 'xbox_one'
77+
PS4 = 'ps4'
78+
ALL = 'all'
79+
80+
_valid = [XBOX_ONE, PS4, ALL]
81+
82+
7583
class Cursor(_Parameter):
7684
@classmethod
7785
def validate(cls, value):

resources/lib/twitch/api/v5/streams.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://dev.twitch.tv/docs/v5/reference/streams/
33

44
from twitch import keys
5-
from twitch.api.parameters import StreamType, Language
5+
from twitch.api.parameters import Boolean, StreamType, Language, Platform
66
from twitch.queries import V5Query as Qry
77
from twitch.queries import query
88

@@ -17,15 +17,21 @@ def by_id(channel_id, stream_type=StreamType.LIVE):
1717

1818

1919
# required scope: none
20+
# platform undocumented / unsupported
2021
@query
2122
def get_all(game=None, channel_ids=None, community_id=None, language=Language.ALL,
22-
stream_type=StreamType.LIVE, limit=25, offset=0):
23+
stream_type=StreamType.LIVE, platform=Platform.ALL, limit=25, offset=0):
2324
q = Qry('streams')
2425
q.add_param(keys.GAME, game)
2526
q.add_param(keys.CHANNEL, channel_ids)
2627
q.add_param(keys.COMMUNITY_ID, community_id)
2728
q.add_param(keys.LANGUAGE, Language.validate(language), Language.ALL)
2829
q.add_param(keys.STREAM_TYPE, StreamType.validate(stream_type), StreamType.LIVE)
30+
platform = Platform.validate(platform)
31+
if platform == Platform.XBOX_ONE:
32+
q.add_param(keys.XBOX_HEARTBEAT, Boolean.TRUE)
33+
elif platform == Platform.PS4:
34+
q.add_param(keys.SCE_PLATFORM, 'PS4')
2935
q.add_param(keys.LIMIT, limit, 25)
3036
q.add_param(keys.OFFSET, offset, 0)
3137
return q

resources/lib/twitch/keys.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
QUERY = 'query'
5656
REASON = 'reason'
5757
RULES = 'rules'
58+
SCE_PLATFORM = 'sce_platform'
5859
SHARE = 'share'
5960
SIG = 'sig'
6061
SORT = 'sort'
@@ -75,3 +76,4 @@
7576
USER_ID = 'user_id'
7677
VIDEO_ID = 'video_id'
7778
VOD = 'vod'
79+
XBOX_HEARTBEAT = 'xbox_heartbeat'

0 commit comments

Comments
 (0)