Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions resources/lib/twitch/api/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,38 @@ def validate(cls, value):

class Language(_Parameter):
ALL = 'all'
# add twitch supported language codes
_valid = [ALL]
EN = 'en'
DA = 'da'
DE = 'de'
ES = 'es'
FR = 'fr'
IT = 'it'
HU = 'hu'
NL = 'nl'
NO = 'no'
PL = 'pl'
OTHER = 'other'
ASL = 'asl'
KO = 'ko'
JA = 'ja'
ZH = 'zh'
TH = 'th'
AR = 'ar'
RU = 'ru'
BG = 'bg'
EL = 'el'
CS = 'cs'
TR = 'tr'
VI = 'vi'
SV = 'sv'
FI = 'fi'
SK = 'sk'
PT = 'pt'

_valid = [ALL, EN, DA, DE, ES, FR, IT, HU, NL,
NO, PL, OTHER, ASL, KO, JA, ZH, TH,
AR, RU, BG, EL, CS, TR, VI, SV, FI,
SK, PT]

@classmethod
def validate(cls, value):
Expand Down
42 changes: 41 additions & 1 deletion resources/lib/twitch/api/v5/games.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- encoding: utf-8 -*-
# https://dev.twitch.tv/docs/v5/reference/games/

from twitch import keys
from twitch import keys, methods
from twitch.queries import V5Query as Qry
from twitch.queries import HiddenApiQuery as HQry
from twitch.queries import query


Expand All @@ -13,3 +14,42 @@ def get_top(limit=10, offset=0):
q.add_param(keys.LIMIT, limit, 10)
q.add_param(keys.OFFSET, offset, 0)
return q


# required scope: none
# undocumented / unsupported
@query
def check_follows(username, name):
q = HQry('users/{username}/follows/games/isFollowing')
q.add_urlkw(keys.USERNAME, username)
q.add_param(keys.NAME, name)
return q


# required scope: none
# undocumented / unsupported
@query
def get_followed(username):
q = HQry('users/{username}/follows/games')
q.add_urlkw(keys.USERNAME, username)
return q


# required scope: user_follows_edit
# undocumented / unsupported
@query
def follow(username, name):
q = HQry('users/{username}/follows/games/follow', method=methods.PUT)
q.add_urlkw(keys.USERNAME, username)
q.add_data(keys.NAME, name)
return q


# required scope: user_follows_edit
# undocumented / unsupported
@query
def unfollow(username, name):
q = HQry('users/{username}/follows/games/unfollow', method=methods.DELETE)
q.add_urlkw(keys.USERNAME, username)
q.add_data(keys.NAME, name)
return q
1 change: 1 addition & 0 deletions resources/lib/twitch/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
TOKEN = 'token'
TYPE = 'type'
USER = 'user'
USERNAME = 'username'
USER_AGENT = 'User-Agent'
USER_AGENT_STRING = ('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) '
'Gecko/20100101 Firefox/6.0')
Expand Down