diff --git a/addon.xml b/addon.xml index 2391c87..e7c9957 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -9,7 +9,7 @@ all -[add] add platform parameter to usher +[upd] Mark communities endpoints and queries as deprecated icon.png diff --git a/changelog.txt b/changelog.txt index 20210f9..a5683ff 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +2.0.8 +[upd] Mark communities endpoints and queries as deprecated + 2.0.7 [add] add platform parameter to usher diff --git a/resources/lib/twitch/api/helix/streams.py b/resources/lib/twitch/api/helix/streams.py index 1716d6a..10f7ff1 100644 --- a/resources/lib/twitch/api/helix/streams.py +++ b/resources/lib/twitch/api/helix/streams.py @@ -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()) @@ -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()) diff --git a/resources/lib/twitch/api/v5/channels.py b/resources/lib/twitch/api/v5/channels.py index 5200833..ae74902 100644 --- a/resources/lib/twitch/api/v5/channels.py +++ b/resources/lib/twitch/api/v5/channels.py @@ -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 @@ -154,7 +156,7 @@ 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) @@ -162,8 +164,10 @@ def set_community(channel_id, community_id): # 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) @@ -171,9 +175,10 @@ def set_communities(channel_id, community_ids): # 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 diff --git a/resources/lib/twitch/api/v5/communities.py b/resources/lib/twitch/api/v5/communities.py index 4e63d1e..26e32c9 100644 --- a/resources/lib/twitch/api/v5/communities.py +++ b/resources/lib/twitch/api/v5/communities.py @@ -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) @@ -46,8 +54,10 @@ 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==') @@ -55,8 +65,10 @@ def get_top(limit=10, cursor='MA=='): # 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) @@ -65,8 +77,10 @@ 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) @@ -74,8 +88,10 @@ def ban_user(community_id, user_id): # 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) @@ -83,8 +99,10 @@ def unban_user(community_id, user_id): # 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) @@ -92,16 +110,20 @@ def create_avatar(community_id, avatar_image): # 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) @@ -109,24 +131,30 @@ def create_cover(community_id, cover_image): # 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) @@ -134,8 +162,10 @@ def add_moderator(community_id, user_id): # 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) @@ -143,16 +173,20 @@ def delete_moderator(community_id, user_id): # 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) @@ -160,8 +194,10 @@ def report_violation(community_id, channel_id): # 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) @@ -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) @@ -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) diff --git a/resources/lib/twitch/api/v5/streams.py b/resources/lib/twitch/api/v5/streams.py index a6d8beb..a5bdba7 100644 --- a/resources/lib/twitch/api/v5/streams.py +++ b/resources/lib/twitch/api/v5/streams.py @@ -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) diff --git a/resources/lib/twitch/log.py b/resources/lib/twitch/log.py index 35c725d..f6c2ca2 100644 --- a/resources/lib/twitch/log.py +++ b/resources/lib/twitch/log.py @@ -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)) diff --git a/resources/lib/twitch/oauth/v5/scopes.py b/resources/lib/twitch/oauth/v5/scopes.py index 561a012..6b3c6ed 100644 --- a/resources/lib/twitch/oauth/v5/scopes.py +++ b/resources/lib/twitch/oauth/v5/scopes.py @@ -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.