Skip to content

Commit fb680c3

Browse files
authored
Merge pull request #10 from anxdpanic/dev
add undocumented games endpoints (following)
2 parents 0c514cb + 850e97d commit fb680c3

3 files changed

Lines changed: 74 additions & 3 deletions

File tree

resources/lib/twitch/api/parameters.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,38 @@ def validate(cls, value):
8484

8585
class Language(_Parameter):
8686
ALL = 'all'
87-
# add twitch supported language codes
88-
_valid = [ALL]
87+
EN = 'en'
88+
DA = 'da'
89+
DE = 'de'
90+
ES = 'es'
91+
FR = 'fr'
92+
IT = 'it'
93+
HU = 'hu'
94+
NL = 'nl'
95+
NO = 'no'
96+
PL = 'pl'
97+
OTHER = 'other'
98+
ASL = 'asl'
99+
KO = 'ko'
100+
JA = 'ja'
101+
ZH = 'zh'
102+
TH = 'th'
103+
AR = 'ar'
104+
RU = 'ru'
105+
BG = 'bg'
106+
EL = 'el'
107+
CS = 'cs'
108+
TR = 'tr'
109+
VI = 'vi'
110+
SV = 'sv'
111+
FI = 'fi'
112+
SK = 'sk'
113+
PT = 'pt'
114+
115+
_valid = [ALL, EN, DA, DE, ES, FR, IT, HU, NL,
116+
NO, PL, OTHER, ASL, KO, JA, ZH, TH,
117+
AR, RU, BG, EL, CS, TR, VI, SV, FI,
118+
SK, PT]
89119

90120
@classmethod
91121
def validate(cls, value):

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# -*- encoding: utf-8 -*-
22
# https://dev.twitch.tv/docs/v5/reference/games/
33

4-
from twitch import keys
4+
from twitch import keys, methods
55
from twitch.queries import V5Query as Qry
6+
from twitch.queries import HiddenApiQuery as HQry
67
from twitch.queries import query
78

89

@@ -13,3 +14,42 @@ def get_top(limit=10, offset=0):
1314
q.add_param(keys.LIMIT, limit, 10)
1415
q.add_param(keys.OFFSET, offset, 0)
1516
return q
17+
18+
19+
# required scope: none
20+
# undocumented / unsupported
21+
@query
22+
def check_follows(username, name):
23+
q = HQry('users/{username}/follows/games/isFollowing')
24+
q.add_urlkw(keys.USERNAME, username)
25+
q.add_param(keys.NAME, name)
26+
return q
27+
28+
29+
# required scope: none
30+
# undocumented / unsupported
31+
@query
32+
def get_followed(username):
33+
q = HQry('users/{username}/follows/games')
34+
q.add_urlkw(keys.USERNAME, username)
35+
return q
36+
37+
38+
# required scope: user_follows_edit
39+
# undocumented / unsupported
40+
@query
41+
def follow(username, name):
42+
q = HQry('users/{username}/follows/games/follow', method=methods.PUT)
43+
q.add_urlkw(keys.USERNAME, username)
44+
q.add_data(keys.NAME, name)
45+
return q
46+
47+
48+
# required scope: user_follows_edit
49+
# undocumented / unsupported
50+
@query
51+
def unfollow(username, name):
52+
q = HQry('users/{username}/follows/games/unfollow', method=methods.DELETE)
53+
q.add_urlkw(keys.USERNAME, username)
54+
q.add_data(keys.NAME, name)
55+
return q

resources/lib/twitch/keys.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
TOKEN = 'token'
6969
TYPE = 'type'
7070
USER = 'user'
71+
USERNAME = 'username'
7172
USER_AGENT = 'User-Agent'
7273
USER_AGENT_STRING = ('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) '
7374
'Gecko/20100101 Firefox/6.0')

0 commit comments

Comments
 (0)