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
4 changes: 2 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.7" provider-name="A Talented Community">
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.8" provider-name="A Talented Community">
<requires>
<import addon="xbmc.python" version="2.20.0"/>
<import addon="script.module.six" version="1.11.0"/>
Expand All @@ -9,7 +9,7 @@
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<news>
[add] add platform parameter to usher
[upd] Mark communities endpoints and queries as deprecated
</news>
<assets>
<icon>icon.png</icon>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.0.8
[upd] Mark communities endpoints and queries as deprecated

2.0.7
[add] add platform parameter to usher

Expand Down
6 changes: 2 additions & 4 deletions resources/lib/twitch/api/helix/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@

# required scope: none
@query
def get_streams(community_id=list(), game_id=list(), user_id=list(),
def get_streams(game_id=list(), user_id=list(),
user_login=list(), language=list(), after='MA==',
before='MA==', first=20, use_app_token=False):
q = Qry('streams', use_app_token=use_app_token)
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
q.add_param(keys.COMMUNITY_ID, ItemCount().validate(community_id), list())
q.add_param(keys.GAME_ID, ItemCount().validate(game_id), list())
q.add_param(keys.USER_ID, ItemCount().validate(user_id), list())
q.add_param(keys.USER_LOGIN, ItemCount().validate(user_login), list())
Expand All @@ -41,14 +40,13 @@ def get_streams(community_id=list(), game_id=list(), user_id=list(),

# required scope: none
@query
def get_metadata(community_id=list(), game_id=list(), user_id=list(),
def get_metadata(game_id=list(), user_id=list(),
user_login=list(), language=list(), after='MA==',
before='MA==', first=20, use_app_token=False):
q = Qry('streams/metadata', use_app_token=use_app_token)
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)
q.add_param(keys.COMMUNITY_ID, ItemCount().validate(community_id), list())
q.add_param(keys.GAME_ID, ItemCount().validate(game_id), list())
q.add_param(keys.USER_ID, ItemCount().validate(user_id), list())
q.add_param(keys.USER_LOGIN, ItemCount().validate(user_login), list())
Expand Down
11 changes: 8 additions & 3 deletions resources/lib/twitch/api/v5/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ def reset_stream_key(channel_id):
# deprecated
@query
def get_community(channel_id):
log.deprecated_query('channels.get_community', 'channels.get_communities')
log.deprecated_query('channels.get_community')
q = Qry('channels/{channel_id}/community')
q.add_urlkw(keys.CHANNEL_ID, channel_id)
return q


# required scope: none
# deprecated
@query
def get_communities(channel_id):
log.deprecated_query('channels.get_community')
q = Qry('channels/{channel_id}/communities', use_token=False)
q.add_urlkw(keys.CHANNEL_ID, channel_id)
return q
Expand All @@ -154,26 +156,29 @@ def get_communities(channel_id):
# deprecated
@query
def set_community(channel_id, community_id):
log.deprecated_query('channels.set_community', 'channels.set_communities')
log.deprecated_query('channels.set_community')
q = Qry('channels/{channel_id}/community/{community_id}', method=methods.PUT)
q.add_urlkw(keys.CHANNEL_ID, channel_id)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
return q


# required scope: channel_editor
# deprecated
@query
def set_communities(channel_id, community_ids):
log.deprecated_query('channels.set_communities')
q = Qry('channels/{channel_id}/communities', method=methods.PUT)
q.add_urlkw(keys.CHANNEL_ID, channel_id)
q.add_data(keys.COMMUNITY_IDS, community_ids)
return q


# required scope: channel_editor
# deprecated action: act on single community, new action: act on all communities
# deprecated
@query
def delete_from_community(channel_id):
log.deprecated_query('channels.delete_from_community')
q = Qry('channels/{channel_id}/community', method=methods.DELETE)
q.add_urlkw(keys.CHANNEL_ID, channel_id)
return q
40 changes: 40 additions & 0 deletions resources/lib/twitch/api/v5/communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,38 @@

from ... import keys, methods
from ...api.parameters import Cursor
from ...log import log
from ...queries import V5Query as Qry
from ...queries import query

# This endpoint is deprecated

# required scope: none
# deprecated
@query
def by_name(name):
log.deprecated_endpoint('communities')
q = Qry('communities', use_token=False)
q.add_param(keys.NAME, name)
return q


# required scope: none
# deprecated
@query
def by_id(community_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}', use_token=False)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
return q


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


# required scope: none
# deprecated
@query
def get_top(limit=10, cursor='MA=='):
log.deprecated_endpoint('communities')
q = Qry('communities/top', use_token=False)
q.add_param(keys.LIMIT, limit, 10)
q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==')
return q


# required scope: communities_moderate
# deprecated
@query
def get_bans(community_id, limit=10, cursor='MA=='):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/bans')
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_param(keys.LIMIT, limit, 10)
Expand All @@ -65,103 +77,127 @@ def get_bans(community_id, limit=10, cursor='MA=='):


# required scope: communities_moderate
# deprecated
@query
def ban_user(community_id, user_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/bans/{user_id}', method=methods.PUT)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_urlkw(keys.USER_ID, user_id)
return q


# required scope: communities_moderate
# deprecated
@query
def unban_user(community_id, user_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/bans/{user_id}', method=methods.DELETE)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_urlkw(keys.USER_ID, user_id)
return q


# required scope: communities_edit
# deprecated
@query
def create_avatar(community_id, avatar_image):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/images/avatar', method=methods.POST)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_urlkw(keys.AVATAR_IMAGE, avatar_image)
return q


# required scope: communities_edit
# deprecated
@query
def delete_avatar(community_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/images/avatar', method=methods.DELETE)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
return q


# required scope: communities_edit
# deprecated
@query
def create_cover(community_id, cover_image):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/images/cover', method=methods.POST)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_urlkw(keys.COVER_IMAGE, cover_image)
return q


# required scope: communities_edit
# deprecated
@query
def delete_cover(community_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/images/cover', method=methods.DELETE)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
return q


# required scope: communities_edit
# deprecated
@query
def get_moderators(community_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/moderators')
q.add_urlkw(keys.COMMUNITY_ID, community_id)
return q


# required scope: communities_edit
# deprecated
@query
def add_moderator(community_id, user_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/moderators/{user_id}', method=methods.PUT)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_urlkw(keys.USER_ID, user_id)
return q


# required scope: communities_edit
# deprecated
@query
def delete_moderator(community_id, user_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/moderators/{user_id}', method=methods.DELETE)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_urlkw(keys.USER_ID, user_id)
return q


# required scope: any
# deprecated
@query
def get_permissions(community_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/permissions')
q.add_urlkw(keys.COMMUNITY_ID, community_id)
return q


# required scope: none
# deprecated
@query
def report_violation(community_id, channel_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/report_channel', use_token=False, method=methods.POST)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_data(keys.CHANNEL_ID, channel_id)
return q


# required scope: communities_moderate
# deprecated
@query
def get_timeouts(community_id, limit=10, cursor='MA=='):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/timeouts')
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_param(keys.LIMIT, limit, 10)
Expand All @@ -170,8 +206,10 @@ def get_timeouts(community_id, limit=10, cursor='MA=='):


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


# required scope: communities_moderate
# deprecated
@query
def delete_timeout(community_id, user_id):
log.deprecated_endpoint('communities')
q = Qry('communities/{community_id}/timeouts/{user_id}', method=methods.DELETE)
q.add_urlkw(keys.COMMUNITY_ID, community_id)
q.add_urlkw(keys.USER_ID, user_id)
Expand Down
3 changes: 1 addition & 2 deletions resources/lib/twitch/api/v5/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ def by_id(channel_id, stream_type=StreamType.LIVE):
# required scope: none
# platform undocumented / unsupported
@query
def get_all(game=None, channel_ids=None, community_id=None, language=Language.ALL,
def get_all(game=None, channel_ids=None, language=Language.ALL,
stream_type=StreamType.LIVE, platform=Platform.ALL, limit=25, offset=0):
q = Qry('streams', use_token=False)
q.add_param(keys.GAME, game)
q.add_param(keys.CHANNEL, channel_ids)
q.add_param(keys.COMMUNITY_ID, community_id)
q.add_param(keys.BROADCASTER_LANGUAGE, Language.validate(language), Language.ALL)
q.add_param(keys.STREAM_TYPE, StreamType.validate(stream_type), StreamType.LIVE)
platform = Platform.validate(platform)
Expand Down
10 changes: 8 additions & 2 deletions resources/lib/twitch/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ def critical(self, message):
else:
self._log.critical(message)

def deprecated_query(self, old, new):
self.warning('DEPRECATED call to |{0}| detected, please use |{1}| instead'.format(old, new))
def deprecated_query(self, old, new=None):
if new:
self.warning('DEPRECATED call to |{0}| detected, please use |{1}| instead'.format(old, new))
else:
self.warning('DEPRECATED call to |{0}| detected, no alternatives available'.format(old))

def deprecated_endpoint(self, old):
self.warning('DEPRECATED call to |{0}| endpoint detected'.format(old))

def deprecated_api_version(self, old, new, eol_date):
self.warning('API version |{0}| is deprecated, update to |{1}| by |{2}|'.format(old, new, eol_date))
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/twitch/oauth/v5/scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
channel_feed_read = 'channel_feed_read' # View a channel feed.
channel_feed_edit = 'channel_feed_edit' # Add posts and reactions to a channel feed.
collections_edit = 'collections_edit' # Manage a user's collections (of videos).
communities_edit = 'communities_edit' # Manage a user's communities.
communities_moderate = 'communities_moderate' # Manage community moderators.
communities_edit = 'communities_edit' # Manage a user's communities. * DEPRECATED
communities_moderate = 'communities_moderate' # Manage community moderators. * DEPRECATED
viewing_activity_read = 'viewing_activity_read' # Turn on Viewer Heartbeat Service ability to record user data.
openid = 'openid' # Use OpenID Connect authentication.