Skip to content

Commit 09aba58

Browse files
authored
Merge pull request #47 from anxdpanic/dev
2.0.2
2 parents 7d2dbbd + cb26f17 commit 09aba58

21 files changed

+246
-52
lines changed

addon.xml

Lines changed: 6 additions & 6 deletions
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.1" provider-name="A Talented Community">
2+
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.2" provider-name="A Talented Community">
33
<requires>
44
<import addon="xbmc.python" version="2.20.0"/>
55
<import addon="script.module.six" version="1.9.0"/>
@@ -9,16 +9,16 @@
99
<extension point="xbmc.addon.metadata">
1010
<platform>all</platform>
1111
<news>
12-
[fix] clips usher
13-
[chg] to relative imports
14-
[upd] deprecation/removal dates
12+
[fix] Python 3 compat.
13+
[add] fast_bread param to usher
14+
[add/upd] helix endpoints
1515
</news>
1616
<assets>
1717
<icon>icon.png</icon>
1818
</assets>
1919
<platform>all</platform>
20-
<summary lang="en">Module for interaction with the Twitch.tv API</summary>
21-
<description lang="en">python-twitch for Kodi is module for interaction with the Twitch.tv API based on python-twitch by ingwinlu.</description>
20+
<summary lang="en_GB">Module for interaction with the Twitch.tv API</summary>
21+
<description lang="en_GB">python-twitch for Kodi is module for interaction with the Twitch.tv API based on python-twitch by ingwinlu.</description>
2222
<license>GNU GENERAL PUBLIC LICENSE. Version 3, 29 June 2007</license>
2323
<forum> </forum>
2424
<source>https://github.com/MrSprigster/script.module.python.twitch</source>

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.0.2
2+
[fix] Python 3 compat.
3+
[add] fast_bread param to usher
4+
[add/upd] helix endpoints
5+
16
2.0.1
27
[fix] clips usher
38
[chg] to relative imports

resources/lib/twitch/api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['v5', 'default', 'helix', 'parameters', 'usher']
44

5-
from . import v5 # V5 is deprecated and will be removed entirely on 12/31/18
5+
from . import v5 # V5 is deprecated and will be removed entirely on TBD
66
from . import v5 as default
77
from . import helix
88
from . import parameters
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# -*- encoding: utf-8 -*-
22
# https://dev.twitch.tv/docs/
33

4-
__all__ = ['clips', 'games', 'streams', 'users', 'videos']
4+
__all__ = ['analytics', 'bits', 'clips', 'entitlements', 'games', 'streams', 'users', 'videos', 'webhooks']
55

6+
from . import analytics # NOQA
7+
from . import bits # NOQA
68
from . import clips # NOQA
9+
from . import entitlements # NOQA
710
from . import games # NOQA
811
from . import streams # NOQA
912
from . import users # NOQA
1013
from . import videos # NOQA
14+
from . import webhooks # NOQA
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://dev.twitch.tv/docs/api/reference
3+
4+
from ..parameters import IntRange, Cursor, ReportType
5+
from ... import keys
6+
from ...queries import HelixQuery as Qry
7+
from ...queries import query
8+
9+
10+
# required scope: analytics:read:extensions
11+
@query
12+
def extensions(started_at='', ended_at='', extension_id='', report_type='', after='MA==', first=20, use_app_token=False):
13+
q = Qry('analytics/extensions', use_app_token=use_app_token)
14+
q.add_param(keys.STARTED_AT, started_at, '')
15+
q.add_param(keys.ENDED_AT, ended_at, '')
16+
q.add_param(keys.EXTENSION_ID, extension_id, '')
17+
if report_type:
18+
q.add_param(keys.TYPE, ReportType.validate(report_type))
19+
if not extension_id:
20+
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
21+
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
22+
23+
return q
24+
25+
26+
# required scope: analytics:read:games
27+
@query
28+
def games(started_at='', ended_at='', game_id='', report_type='', after='MA==', first=20, use_app_token=False):
29+
q = Qry('analytics/games', use_app_token=use_app_token)
30+
q.add_param(keys.STARTED_AT, started_at, '')
31+
q.add_param(keys.ENDED_AT, ended_at, '')
32+
q.add_param(keys.GAME_ID, game_id, '')
33+
if report_type:
34+
q.add_param(keys.TYPE, ReportType.validate(report_type))
35+
if not game_id:
36+
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
37+
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
38+
39+
return q
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://dev.twitch.tv/docs/api/reference
3+
4+
from ..parameters import PeriodHelix, IntRange
5+
from ... import keys
6+
from ...queries import HelixQuery as Qry
7+
from ...queries import query
8+
9+
10+
# required scope: bits:read
11+
@query
12+
def get_bits_leaderboard(count=10, period=PeriodHelix.ALL, started_at='', user_id='', use_app_token=False):
13+
q = Qry('bits/leaderboard', use_app_token=use_app_token)
14+
q.add_param(keys.COUNT, IntRange(1, 100).validate(count), 10)
15+
q.add_param(keys.PERIOD, PeriodHelix.validate(period), PeriodHelix.ALL)
16+
if period != PeriodHelix.ALL:
17+
q.add_param(keys.STARTED_AT, started_at, '')
18+
q.add_param(keys.USER_ID, user_id, '')
19+
20+
return q
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
# -*- encoding: utf-8 -*-
22
# https://dev.twitch.tv/docs/api/reference
33

4+
from ..parameters import Boolean, Cursor, IntRange, ItemCount
45
from ... import keys, methods
56
from ...queries import HelixQuery as Qry
67
from ...queries import query
78

89

910
# required scope: none
1011
@query
11-
def get_clip(clip_id, use_app_token=False):
12+
def get_clip(broadcaster_id='', game_id='', clip_id=list(),
13+
after='MA==', before='MA==', first=20, use_app_token=False):
1214
q = Qry('clips', use_app_token=use_app_token)
13-
q.add_param(keys.ID, clip_id, '')
15+
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
16+
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
17+
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
18+
q.add_param(keys.BROADCASTER_ID, broadcaster_id, '')
19+
q.add_param(keys.GAME_ID, game_id, '')
20+
q.add_param(keys.ID, ItemCount().validate(clip_id), list())
1421

1522
return q
1623

1724

1825
# required scope: clips:edit
1926
@query
20-
def create_clip(broadcaster_id, use_app_token=False):
27+
def create_clip(broadcaster_id, has_delay=Boolean.FALSE, use_app_token=False):
2128
q = Qry('clips', use_app_token=use_app_token, method=methods.POST)
2229
q.add_param(keys.BROADCASTER_ID, broadcaster_id, '')
30+
q.add_param(keys.HAS_DELAY, Boolean.validate(has_delay), Boolean.FALSE)
2331

2432
return q
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://dev.twitch.tv/docs/api/reference
3+
4+
from ..parameters import EntitlementType
5+
from ... import keys
6+
from ...queries import HelixQuery as Qry
7+
from ...queries import query
8+
9+
10+
# required scope: none
11+
# requires app access token
12+
@query
13+
def upload(manifest_id, entitlement_type=EntitlementType.BULK_DROPS_GRANT):
14+
q = Qry('entitlements/upload', use_app_token=True)
15+
q.add_param(keys.MANIFEST_ID, manifest_id)
16+
q.add_param(keys.TYPE, EntitlementType.validate(entitlement_type))
17+
18+
return q

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

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

44
from ... import keys
5-
from ...api.parameters import Cursor
5+
from ...api.parameters import Cursor, IntRange, ItemCount
66
from ...queries import HelixQuery as Qry
77
from ...queries import query
88

@@ -11,8 +11,9 @@
1111
@query
1212
def get_games(game_id=list(), game_name=list(), use_app_token=False):
1313
q = Qry('games', use_app_token=use_app_token)
14-
q.add_param(keys.ID, game_id, list())
15-
q.add_param(keys.NAME, game_name, list())
14+
q.add_param(keys.ID, ItemCount().validate(game_id), list())
15+
q.add_param(keys.NAME, ItemCount().validate(game_name), list())
16+
1617
return q
1718

1819

@@ -22,6 +23,6 @@ def get_top(after='MA==', before='MA==', first=20, use_app_token=False):
2223
q = Qry('games/top', use_app_token=use_app_token)
2324
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
2425
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
25-
q.add_param(keys.FIRST, first, 20)
26+
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
2627

2728
return q

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@
22
# https://dev.twitch.tv/docs/api/reference
33

44
from ... import keys
5-
from ...api.parameters import Cursor, Language, StreamTypeHelix
5+
from ...api.parameters import Cursor, Language, IntRange, ItemCount
66
from ...queries import HelixQuery as Qry
77
from ...queries import query
88

99

1010
# required scope: none
1111
@query
1212
def get_streams(community_id=list(), game_id=list(), user_id=list(),
13-
user_login=list(), stream_type=StreamTypeHelix.ALL, language=list(),
14-
after='MA==', before='MA==', first=20, use_app_token=False):
13+
user_login=list(), language=list(), after='MA==',
14+
before='MA==', first=20, use_app_token=False):
1515
q = Qry('streams', use_app_token=use_app_token)
1616
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
1717
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
18-
q.add_param(keys.FIRST, first, 20)
19-
q.add_param(keys.COMMUNITY_ID, community_id, list())
20-
q.add_param(keys.GAME_ID, game_id, list())
21-
q.add_param(keys.USER_ID, user_id, list())
22-
q.add_param(keys.USER_LOGIN, user_login, list())
23-
q.add_param(keys.TYPE, StreamTypeHelix.validate(stream_type), StreamTypeHelix.ALL)
18+
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
19+
q.add_param(keys.COMMUNITY_ID, ItemCount().validate(community_id), list())
20+
q.add_param(keys.GAME_ID, ItemCount().validate(game_id), list())
21+
q.add_param(keys.USER_ID, ItemCount().validate(user_id), list())
22+
q.add_param(keys.USER_LOGIN, ItemCount().validate(user_login), list())
2423
if isinstance(language, list):
2524
_language = [lang for lang in language if lang in Language.valid()]
26-
q.add_param(keys.LANGUAGE, _language, list())
25+
q.add_param(keys.LANGUAGE, ItemCount().validate(_language), list())
2726
else:
2827
q.add_param(keys.LANGUAGE, Language.validate(language), '')
2928

@@ -33,20 +32,19 @@ def get_streams(community_id=list(), game_id=list(), user_id=list(),
3332
# required scope: none
3433
@query
3534
def get_metadata(community_id=list(), game_id=list(), user_id=list(),
36-
user_login=list(), stream_type=StreamTypeHelix.ALL, language=list(),
37-
after='MA==', before='MA==', first=20, use_app_token=False):
35+
user_login=list(), language=list(), after='MA==',
36+
before='MA==', first=20, use_app_token=False):
3837
q = Qry('streams/metadata', use_app_token=use_app_token)
3938
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
4039
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
41-
q.add_param(keys.FIRST, first, 20)
42-
q.add_param(keys.COMMUNITY_ID, community_id, list())
43-
q.add_param(keys.GAME_ID, game_id, list())
44-
q.add_param(keys.USER_ID, user_id, list())
45-
q.add_param(keys.USER_LOGIN, user_login, list())
46-
q.add_param(keys.TYPE, StreamTypeHelix.validate(stream_type), StreamTypeHelix.ALL)
40+
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
41+
q.add_param(keys.COMMUNITY_ID, ItemCount().validate(community_id), list())
42+
q.add_param(keys.GAME_ID, ItemCount().validate(game_id), list())
43+
q.add_param(keys.USER_ID, ItemCount().validate(user_id), list())
44+
q.add_param(keys.USER_LOGIN, ItemCount().validate(user_login), list())
4745
if isinstance(language, list):
4846
_language = [lang for lang in language if lang in Language.valid()]
49-
q.add_param(keys.LANGUAGE, _language, list())
47+
q.add_param(keys.LANGUAGE, ItemCount().validate(_language), list())
5048
else:
5149
q.add_param(keys.LANGUAGE, Language.validate(language), '')
5250

0 commit comments

Comments
 (0)