Skip to content

Commit dd5ff25

Browse files
authored
Merge pull request #62 from anxdpanic/dev
2.0.6
2 parents 38fde39 + b3b5b87 commit dd5ff25

File tree

9 files changed

+149
-12
lines changed

9 files changed

+149
-12
lines changed

Diff for: addon.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.5" provider-name="A Talented Community">
2+
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.6" provider-name="A Talented Community">
33
<requires>
44
<import addon="xbmc.python" version="2.20.0"/>
55
<import addon="script.module.six" version="1.11.0"/>
@@ -9,9 +9,7 @@
99
<extension point="xbmc.addon.metadata">
1010
<platform>all</platform>
1111
<news>
12-
[add] add frame rate and resolution to returned stream information
13-
[upd] update usher parameters
14-
[upd] use SPDX license identifiers
12+
[add] add missing helix api endpoints
1513
</news>
1614
<assets>
1715
<icon>icon.png</icon>

Diff for: changelog.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.0.6
2+
[add] add missing helix api endpoints
3+
14
2.0.5
25
[add] add frame rate and resolution to returned stream information
36
[upd] update usher parameters

Diff for: resources/lib/twitch/api/helix/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@
22
"""
33
Reference: https://dev.twitch.tv/docs/
44
5-
Copyright (C) 2016-2018 script.module.python.twitch
5+
Copyright (C) 2016-2019 script.module.python.twitch
66
77
This file is part of script.module.python.twitch
88
99
SPDX-License-Identifier: GPL-3.0-only
1010
See LICENSES/GPL-3.0-only for more information.
1111
"""
1212

13-
__all__ = ['analytics', 'bits', 'clips', 'entitlements', 'games', 'streams', 'users', 'videos', 'webhooks']
13+
__all__ = ['analytics', 'bits', 'clips', 'entitlements', 'games', 'streams',
14+
'subscriptions', 'tags', 'users', 'videos', 'webhooks']
1415

1516
from . import analytics # NOQA
1617
from . import bits # NOQA
1718
from . import clips # NOQA
1819
from . import entitlements # NOQA
1920
from . import games # NOQA
2021
from . import streams # NOQA
22+
from . import subscriptions # NOQA
23+
from . import tags # NOQA
2124
from . import users # NOQA
2225
from . import videos # NOQA
2326
from . import webhooks # NOQA

Diff for: resources/lib/twitch/api/helix/entitlements.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
"""
33
Reference: https://dev.twitch.tv/docs/api/reference
44
5-
Copyright (C) 2016-2018 script.module.python.twitch
5+
Copyright (C) 2016-2019 script.module.python.twitch
66
77
This file is part of script.module.python.twitch
88
99
SPDX-License-Identifier: GPL-3.0-only
1010
See LICENSES/GPL-3.0-only for more information.
1111
"""
1212

13-
from ..parameters import EntitlementType
13+
from ..parameters import EntitlementType, ItemCount
1414
from ... import keys
15+
from ... import methods
1516
from ...queries import HelixQuery as Qry
1617
from ...queries import query
1718

@@ -25,3 +26,25 @@ def upload(manifest_id, entitlement_type=EntitlementType.BULK_DROPS_GRANT):
2526
q.add_param(keys.TYPE, EntitlementType.validate(entitlement_type))
2627

2728
return q
29+
30+
31+
# required scope: none
32+
# requires app access token
33+
@query
34+
def get_code_status(code, user_id):
35+
q = Qry('entitlements/codes', use_app_token=True, method=methods.GET)
36+
q.add_param(keys.CODE, ItemCount(max_items=20).validate(code), list())
37+
q.add_param(keys.USER_ID, user_id)
38+
39+
return q
40+
41+
42+
# required scope: none
43+
# requires app access token
44+
@query
45+
def redeem_code(code, user_id):
46+
q = Qry('entitlements/codes', use_app_token=True, method=methods.POST)
47+
q.add_param(keys.CODE, ItemCount(max_items=20).validate(code), list())
48+
q.add_param(keys.USER_ID, user_id)
49+
50+
return q

Diff for: resources/lib/twitch/api/helix/streams.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
Reference: https://dev.twitch.tv/docs/api/reference
44
5-
Copyright (C) 2016-2018 script.module.python.twitch
5+
Copyright (C) 2016-2019 script.module.python.twitch
66
77
This file is part of script.module.python.twitch
88
@@ -12,6 +12,7 @@
1212

1313
from ... import keys
1414
from ...api.parameters import Cursor, Language, IntRange, ItemCount
15+
from ... import methods
1516
from ...queries import HelixQuery as Qry
1617
from ...queries import query
1718

@@ -58,3 +59,26 @@ def get_metadata(community_id=list(), game_id=list(), user_id=list(),
5859
q.add_param(keys.LANGUAGE, Language.validate(language), '')
5960

6061
return q
62+
63+
64+
# required scope: user:edit:broadcast
65+
@query
66+
def create_stream_marker(user_id, description=''):
67+
q = Qry('streams/markers', use_app_token=False, method=methods.POST)
68+
q.add_param(keys.USER_ID, user_id)
69+
q.add_param(keys.DESCRIPTION, description, '')
70+
71+
return q
72+
73+
74+
# required scope: user:read:broadcast
75+
@query
76+
def get_stream_markers(user_id, video_id, after='MA==', before='MA==', first=20):
77+
q = Qry('streams/markers', use_app_token=False, method=methods.GET)
78+
q.add_param(keys.USER_ID, user_id)
79+
q.add_param(keys.VIDEO_ID, video_id)
80+
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
81+
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
82+
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
83+
84+
return q

Diff for: resources/lib/twitch/api/helix/subscriptions.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Reference: https://dev.twitch.tv/docs/api/reference
4+
5+
Copyright (C) 2016-2019 script.module.python.twitch
6+
7+
This file is part of script.module.python.twitch
8+
9+
SPDX-License-Identifier: GPL-3.0-only
10+
See LICENSES/GPL-3.0-only for more information.
11+
"""
12+
13+
from ..parameters import ItemCount
14+
from ... import keys, methods
15+
from ...queries import HelixQuery as Qry
16+
from ...queries import query
17+
18+
19+
# required scope: channel:read:subscriptions
20+
@query
21+
def get_broadcaster_subscriptions(broadcaster_id):
22+
q = Qry('subscriptions', use_app_token=False, method=methods.GET)
23+
q.add_param(keys.BROADCASTER_ID, broadcaster_id)
24+
25+
return q
26+
27+
28+
# required scope: channel:read:subscriptions
29+
@query
30+
def get_user_subscriptions(broadcaster_id, user_id):
31+
q = Qry('subscriptions', use_app_token=False, method=methods.GET)
32+
q.add_param(keys.BROADCASTER_ID, broadcaster_id)
33+
q.add_param(keys.USER_ID, ItemCount().validate(user_id), list())
34+
35+
return q

Diff for: resources/lib/twitch/api/helix/tags.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Reference: https://dev.twitch.tv/docs/api/reference
4+
5+
Copyright (C) 2016-2019 script.module.python.twitch
6+
7+
This file is part of script.module.python.twitch
8+
9+
SPDX-License-Identifier: GPL-3.0-only
10+
See LICENSES/GPL-3.0-only for more information.
11+
"""
12+
13+
from ..parameters import Cursor, IntRange, ItemCount
14+
from ... import keys, methods
15+
from ...queries import HelixQuery as Qry
16+
from ...queries import query
17+
18+
19+
# required scope: none
20+
# requires app access token
21+
@query
22+
def get_all_stream_tags(tag_id, after='MA==', first=20):
23+
q = Qry('tags/streams', use_app_token=True, method=methods.GET)
24+
q.add_param(keys.TAG_ID, ItemCount().validate(tag_id), list())
25+
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
26+
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
27+
28+
return q
29+
30+
31+
# required scope: none
32+
# requires app access token
33+
@query
34+
def get_stream_tags(broadcaster_id):
35+
q = Qry('streams/tags', use_app_token=True, method=methods.GET)
36+
q.add_param(keys.BROADCASTER_ID, broadcaster_id)
37+
38+
return q
39+
40+
41+
# required scope: user:edit:broadcast
42+
@query
43+
def replace_stream_tags(broadcaster_id, tag_ids=list()):
44+
q = Qry('tags/streams', use_app_token=False, method=methods.PUT)
45+
q.add_param(keys.BROADCASTER_ID, broadcaster_id)
46+
q.add_param(keys.TAG_IDS, ItemCount().validate(tag_ids), list())
47+
48+
return q

Diff for: resources/lib/twitch/api/parameters.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
See LICENSES/GPL-3.0-only for more information.
1111
"""
1212

13-
from six.moves import xrange
13+
from six.moves import range
1414

1515
from base64 import b64decode
1616

@@ -223,7 +223,7 @@ class IntRange(_Parameter):
223223

224224
@classmethod
225225
def __init__(cls, first, last):
226-
cls._valid = [i for i in xrange(first, last + 1)]
226+
cls._valid = [i for i in range(first, last + 1)]
227227

228228

229229
class ItemCount(object):

Diff for: resources/lib/twitch/keys.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
string constants
44
55
Copyright (C) 2012-2016 python-twitch (https://github.com/ingwinlu/python-twitch)
6-
Copyright (C) 2016-2018 script.module.python.twitch
6+
Copyright (C) 2016-2019 script.module.python.twitch
77
88
This file is part of script.module.python.twitch
99
@@ -29,6 +29,7 @@
2929
CHANNEL_FEED_ENABLED = 'channel_feed_enabled'
3030
CHANNEL_ID = 'channel_id'
3131
CLIP = 'clip'
32+
CODE = 'code'
3233
COLLECTION_ID = 'collection_id'
3334
COMMENT_ID = 'comment_id'
3435
COMMENTS = 'comments'
@@ -100,6 +101,8 @@
100101
STATUS = 'status'
101102
STREAM_TYPE = 'stream_type'
102103
SUMMARY = 'summary'
104+
TAG_ID = 'tag_id'
105+
TAG_IDS = 'tag_ids'
103106
TAG_LIST = 'tag_list'
104107
TARGET_ID = 'target_id'
105108
TEAM = 'team'

0 commit comments

Comments
 (0)