Skip to content

Commit 5fb9fa4

Browse files
authored
Merge pull request #65 from anxdpanic/dev
2.0.8
2 parents 60c78e3 + da6d497 commit 5fb9fa4

File tree

8 files changed

+66
-15
lines changed

8 files changed

+66
-15
lines changed

addon.xml

Lines changed: 2 additions & 2 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.7" provider-name="A Talented Community">
2+
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.8" 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,7 +9,7 @@
99
<extension point="xbmc.addon.metadata">
1010
<platform>all</platform>
1111
<news>
12-
[add] add platform parameter to usher
12+
[upd] Mark communities endpoints and queries as deprecated
1313
</news>
1414
<assets>
1515
<icon>icon.png</icon>

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.0.8
2+
[upd] Mark communities endpoints and queries as deprecated
3+
14
2.0.7
25
[add] add platform parameter to usher
36

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919

2020
# required scope: none
2121
@query
22-
def get_streams(community_id=list(), game_id=list(), user_id=list(),
22+
def get_streams(game_id=list(), user_id=list(),
2323
user_login=list(), language=list(), after='MA==',
2424
before='MA==', first=20, use_app_token=False):
2525
q = Qry('streams', use_app_token=use_app_token)
2626
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
2727
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
2828
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
29-
q.add_param(keys.COMMUNITY_ID, ItemCount().validate(community_id), list())
3029
q.add_param(keys.GAME_ID, ItemCount().validate(game_id), list())
3130
q.add_param(keys.USER_ID, ItemCount().validate(user_id), list())
3231
q.add_param(keys.USER_LOGIN, ItemCount().validate(user_login), list())
@@ -41,14 +40,13 @@ def get_streams(community_id=list(), game_id=list(), user_id=list(),
4140

4241
# required scope: none
4342
@query
44-
def get_metadata(community_id=list(), game_id=list(), user_id=list(),
43+
def get_metadata(game_id=list(), user_id=list(),
4544
user_login=list(), language=list(), after='MA==',
4645
before='MA==', first=20, use_app_token=False):
4746
q = Qry('streams/metadata', use_app_token=use_app_token)
4847
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
4948
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
5049
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
51-
q.add_param(keys.COMMUNITY_ID, ItemCount().validate(community_id), list())
5250
q.add_param(keys.GAME_ID, ItemCount().validate(game_id), list())
5351
q.add_param(keys.USER_ID, ItemCount().validate(user_id), list())
5452
q.add_param(keys.USER_LOGIN, ItemCount().validate(user_login), list())

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,17 @@ def reset_stream_key(channel_id):
136136
# deprecated
137137
@query
138138
def get_community(channel_id):
139-
log.deprecated_query('channels.get_community', 'channels.get_communities')
139+
log.deprecated_query('channels.get_community')
140140
q = Qry('channels/{channel_id}/community')
141141
q.add_urlkw(keys.CHANNEL_ID, channel_id)
142142
return q
143143

144144

145145
# required scope: none
146+
# deprecated
146147
@query
147148
def get_communities(channel_id):
149+
log.deprecated_query('channels.get_community')
148150
q = Qry('channels/{channel_id}/communities', use_token=False)
149151
q.add_urlkw(keys.CHANNEL_ID, channel_id)
150152
return q
@@ -154,26 +156,29 @@ def get_communities(channel_id):
154156
# deprecated
155157
@query
156158
def set_community(channel_id, community_id):
157-
log.deprecated_query('channels.set_community', 'channels.set_communities')
159+
log.deprecated_query('channels.set_community')
158160
q = Qry('channels/{channel_id}/community/{community_id}', method=methods.PUT)
159161
q.add_urlkw(keys.CHANNEL_ID, channel_id)
160162
q.add_urlkw(keys.COMMUNITY_ID, community_id)
161163
return q
162164

163165

164166
# required scope: channel_editor
167+
# deprecated
165168
@query
166169
def set_communities(channel_id, community_ids):
170+
log.deprecated_query('channels.set_communities')
167171
q = Qry('channels/{channel_id}/communities', method=methods.PUT)
168172
q.add_urlkw(keys.CHANNEL_ID, channel_id)
169173
q.add_data(keys.COMMUNITY_IDS, community_ids)
170174
return q
171175

172176

173177
# required scope: channel_editor
174-
# deprecated action: act on single community, new action: act on all communities
178+
# deprecated
175179
@query
176180
def delete_from_community(channel_id):
181+
log.deprecated_query('channels.delete_from_community')
177182
q = Qry('channels/{channel_id}/community', method=methods.DELETE)
178183
q.add_urlkw(keys.CHANNEL_ID, channel_id)
179184
return q

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,38 @@
1212

1313
from ... import keys, methods
1414
from ...api.parameters import Cursor
15+
from ...log import log
1516
from ...queries import V5Query as Qry
1617
from ...queries import query
1718

19+
# This endpoint is deprecated
1820

1921
# required scope: none
22+
# deprecated
2023
@query
2124
def by_name(name):
25+
log.deprecated_endpoint('communities')
2226
q = Qry('communities', use_token=False)
2327
q.add_param(keys.NAME, name)
2428
return q
2529

2630

2731
# required scope: none
32+
# deprecated
2833
@query
2934
def by_id(community_id):
35+
log.deprecated_endpoint('communities')
3036
q = Qry('communities/{community_id}', use_token=False)
3137
q.add_urlkw(keys.COMMUNITY_ID, community_id)
3238
return q
3339

3440

3541
# required scope: communities_edit
42+
# deprecated
3643
@query
3744
def update(community_id, summary=None, description=None,
3845
rules=None, email=None):
46+
log.deprecated_endpoint('communities')
3947
q = Qry('communities/{community_id}', method=methods.PUT)
4048
q.add_urlkw(keys.COMMUNITY_ID, community_id)
4149
q.add_data(keys.SUMMARY, summary)
@@ -46,17 +54,21 @@ def update(community_id, summary=None, description=None,
4654

4755

4856
# required scope: none
57+
# deprecated
4958
@query
5059
def get_top(limit=10, cursor='MA=='):
60+
log.deprecated_endpoint('communities')
5161
q = Qry('communities/top', use_token=False)
5262
q.add_param(keys.LIMIT, limit, 10)
5363
q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==')
5464
return q
5565

5666

5767
# required scope: communities_moderate
68+
# deprecated
5869
@query
5970
def get_bans(community_id, limit=10, cursor='MA=='):
71+
log.deprecated_endpoint('communities')
6072
q = Qry('communities/{community_id}/bans')
6173
q.add_urlkw(keys.COMMUNITY_ID, community_id)
6274
q.add_param(keys.LIMIT, limit, 10)
@@ -65,103 +77,127 @@ def get_bans(community_id, limit=10, cursor='MA=='):
6577

6678

6779
# required scope: communities_moderate
80+
# deprecated
6881
@query
6982
def ban_user(community_id, user_id):
83+
log.deprecated_endpoint('communities')
7084
q = Qry('communities/{community_id}/bans/{user_id}', method=methods.PUT)
7185
q.add_urlkw(keys.COMMUNITY_ID, community_id)
7286
q.add_urlkw(keys.USER_ID, user_id)
7387
return q
7488

7589

7690
# required scope: communities_moderate
91+
# deprecated
7792
@query
7893
def unban_user(community_id, user_id):
94+
log.deprecated_endpoint('communities')
7995
q = Qry('communities/{community_id}/bans/{user_id}', method=methods.DELETE)
8096
q.add_urlkw(keys.COMMUNITY_ID, community_id)
8197
q.add_urlkw(keys.USER_ID, user_id)
8298
return q
8399

84100

85101
# required scope: communities_edit
102+
# deprecated
86103
@query
87104
def create_avatar(community_id, avatar_image):
105+
log.deprecated_endpoint('communities')
88106
q = Qry('communities/{community_id}/images/avatar', method=methods.POST)
89107
q.add_urlkw(keys.COMMUNITY_ID, community_id)
90108
q.add_urlkw(keys.AVATAR_IMAGE, avatar_image)
91109
return q
92110

93111

94112
# required scope: communities_edit
113+
# deprecated
95114
@query
96115
def delete_avatar(community_id):
116+
log.deprecated_endpoint('communities')
97117
q = Qry('communities/{community_id}/images/avatar', method=methods.DELETE)
98118
q.add_urlkw(keys.COMMUNITY_ID, community_id)
99119
return q
100120

101121

102122
# required scope: communities_edit
123+
# deprecated
103124
@query
104125
def create_cover(community_id, cover_image):
126+
log.deprecated_endpoint('communities')
105127
q = Qry('communities/{community_id}/images/cover', method=methods.POST)
106128
q.add_urlkw(keys.COMMUNITY_ID, community_id)
107129
q.add_urlkw(keys.COVER_IMAGE, cover_image)
108130
return q
109131

110132

111133
# required scope: communities_edit
134+
# deprecated
112135
@query
113136
def delete_cover(community_id):
137+
log.deprecated_endpoint('communities')
114138
q = Qry('communities/{community_id}/images/cover', method=methods.DELETE)
115139
q.add_urlkw(keys.COMMUNITY_ID, community_id)
116140
return q
117141

118142

119143
# required scope: communities_edit
144+
# deprecated
120145
@query
121146
def get_moderators(community_id):
147+
log.deprecated_endpoint('communities')
122148
q = Qry('communities/{community_id}/moderators')
123149
q.add_urlkw(keys.COMMUNITY_ID, community_id)
124150
return q
125151

126152

127153
# required scope: communities_edit
154+
# deprecated
128155
@query
129156
def add_moderator(community_id, user_id):
157+
log.deprecated_endpoint('communities')
130158
q = Qry('communities/{community_id}/moderators/{user_id}', method=methods.PUT)
131159
q.add_urlkw(keys.COMMUNITY_ID, community_id)
132160
q.add_urlkw(keys.USER_ID, user_id)
133161
return q
134162

135163

136164
# required scope: communities_edit
165+
# deprecated
137166
@query
138167
def delete_moderator(community_id, user_id):
168+
log.deprecated_endpoint('communities')
139169
q = Qry('communities/{community_id}/moderators/{user_id}', method=methods.DELETE)
140170
q.add_urlkw(keys.COMMUNITY_ID, community_id)
141171
q.add_urlkw(keys.USER_ID, user_id)
142172
return q
143173

144174

145175
# required scope: any
176+
# deprecated
146177
@query
147178
def get_permissions(community_id):
179+
log.deprecated_endpoint('communities')
148180
q = Qry('communities/{community_id}/permissions')
149181
q.add_urlkw(keys.COMMUNITY_ID, community_id)
150182
return q
151183

152184

153185
# required scope: none
186+
# deprecated
154187
@query
155188
def report_violation(community_id, channel_id):
189+
log.deprecated_endpoint('communities')
156190
q = Qry('communities/{community_id}/report_channel', use_token=False, method=methods.POST)
157191
q.add_urlkw(keys.COMMUNITY_ID, community_id)
158192
q.add_data(keys.CHANNEL_ID, channel_id)
159193
return q
160194

161195

162196
# required scope: communities_moderate
197+
# deprecated
163198
@query
164199
def get_timeouts(community_id, limit=10, cursor='MA=='):
200+
log.deprecated_endpoint('communities')
165201
q = Qry('communities/{community_id}/timeouts')
166202
q.add_urlkw(keys.COMMUNITY_ID, community_id)
167203
q.add_param(keys.LIMIT, limit, 10)
@@ -170,8 +206,10 @@ def get_timeouts(community_id, limit=10, cursor='MA=='):
170206

171207

172208
# required scope: communities_moderate
209+
# deprecated
173210
@query
174211
def add_timeout(community_id, user_id, duration=1, reason=None):
212+
log.deprecated_endpoint('communities')
175213
q = Qry('communities/{community_id}/timeouts/{user_id}', method=methods.PUT)
176214
q.add_urlkw(keys.COMMUNITY_ID, community_id)
177215
q.add_urlkw(keys.USER_ID, user_id)
@@ -181,8 +219,10 @@ def add_timeout(community_id, user_id, duration=1, reason=None):
181219

182220

183221
# required scope: communities_moderate
222+
# deprecated
184223
@query
185224
def delete_timeout(community_id, user_id):
225+
log.deprecated_endpoint('communities')
186226
q = Qry('communities/{community_id}/timeouts/{user_id}', method=methods.DELETE)
187227
q.add_urlkw(keys.COMMUNITY_ID, community_id)
188228
q.add_urlkw(keys.USER_ID, user_id)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ def by_id(channel_id, stream_type=StreamType.LIVE):
2828
# required scope: none
2929
# platform undocumented / unsupported
3030
@query
31-
def get_all(game=None, channel_ids=None, community_id=None, language=Language.ALL,
31+
def get_all(game=None, channel_ids=None, language=Language.ALL,
3232
stream_type=StreamType.LIVE, platform=Platform.ALL, limit=25, offset=0):
3333
q = Qry('streams', use_token=False)
3434
q.add_param(keys.GAME, game)
3535
q.add_param(keys.CHANNEL, channel_ids)
36-
q.add_param(keys.COMMUNITY_ID, community_id)
3736
q.add_param(keys.BROADCASTER_LANGUAGE, Language.validate(language), Language.ALL)
3837
q.add_param(keys.STREAM_TYPE, StreamType.validate(stream_type), StreamType.LIVE)
3938
platform = Platform.validate(platform)

resources/lib/twitch/log.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,14 @@ def critical(self, message):
9494
else:
9595
self._log.critical(message)
9696

97-
def deprecated_query(self, old, new):
98-
self.warning('DEPRECATED call to |{0}| detected, please use |{1}| instead'.format(old, new))
97+
def deprecated_query(self, old, new=None):
98+
if new:
99+
self.warning('DEPRECATED call to |{0}| detected, please use |{1}| instead'.format(old, new))
100+
else:
101+
self.warning('DEPRECATED call to |{0}| detected, no alternatives available'.format(old))
102+
103+
def deprecated_endpoint(self, old):
104+
self.warning('DEPRECATED call to |{0}| endpoint detected'.format(old))
99105

100106
def deprecated_api_version(self, old, new, eol_date):
101107
self.warning('API version |{0}| is deprecated, update to |{1}| by |{2}|'.format(old, new, eol_date))

resources/lib/twitch/oauth/v5/scopes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
channel_feed_read = 'channel_feed_read' # View a channel feed.
2626
channel_feed_edit = 'channel_feed_edit' # Add posts and reactions to a channel feed.
2727
collections_edit = 'collections_edit' # Manage a user's collections (of videos).
28-
communities_edit = 'communities_edit' # Manage a user's communities.
29-
communities_moderate = 'communities_moderate' # Manage community moderators.
28+
communities_edit = 'communities_edit' # Manage a user's communities. * DEPRECATED
29+
communities_moderate = 'communities_moderate' # Manage community moderators. * DEPRECATED
3030
viewing_activity_read = 'viewing_activity_read' # Turn on Viewer Heartbeat Service ability to record user data.
3131
openid = 'openid' # Use OpenID Connect authentication.

0 commit comments

Comments
 (0)