def get_videos(self, video_ids=None, user_id=None, game_id=None, after=None, before=None, page_size=20, language=None, period=PERIOD_ALL, sort=VIDEO_SORT_TIME, video_type=VIDEO_TYPE_ALL): if video_ids and len(video_ids) > 100: raise TwitchAttributeException( 'Maximum of 100 Video IDs can be supplied') params = { 'id': video_ids, 'user_id': user_id, 'game_id': game_id, } if user_id or game_id: if page_size > 100: raise TwitchAttributeException( 'Maximum number of objects to return is 100') if period not in PERIODS: raise TwitchAttributeException( 'Invalid value for period. Valid values are {}'.format( PERIODS)) if sort not in VIDEO_SORTS: raise TwitchAttributeException( 'Invalid value for sort. Valid values are {}'.format( VIDEO_SORTS)) if video_type not in VIDEO_TYPES: raise TwitchAttributeException( 'Invalid value for video_type. Valid values are {}'.format( VIDEO_TYPES)) params['after'] = after params['before'] = before params['first'] = page_size params['language'] = language params['period'] = period params['sort'] = sort params['type'] = video_type return APICursor(client_id=self._client_id, oauth_token=self._oauth_token, path='videos', resource=Video, params=params) else: return APIGet(client_id=self._client_id, oauth_token=self._oauth_token, path='videos', resource=Video, params=params).fetch()
def get_users(self, login_names=[], ids=[]): """https://dev.twitch.tv/docs/api/reference#get-users""" if len(login_names) + len(ids) > 100: raise TwitchAttributeException("Sum of names and ids must not exceed 100!") params = {"login": login_names, "id": ids} return APIGet( client_id=self._client_id, oauth_token=self._oauth_token, path="users", resource=User, params=params, ).fetch()
def get_clips( self, broadcaster_id=None, game_id=None, clip_ids=None, after=None, before=None, started_at=None, ended_at=None, page_size=20, ): if not broadcaster_id and not clip_ids and not game_id: raise TwitchAttributeException( "At least one of the following parameters must be provided " "[broadcaster_id, clip_ids, game_id]" ) if clip_ids and len(clip_ids) > 100: raise TwitchAttributeException("Maximum of 100 Clip IDs can be supplied") if page_size > 100: raise TwitchAttributeException("Maximum number of objects to return is 100") params = { "broadcaster_id": broadcaster_id, "game_id": game_id, "id": clip_ids, "after": after, "before": before, "started_at": started_at, "ended_at": ended_at, } if broadcaster_id or game_id: params["first"] = page_size return APICursor( client_id=self._client_id, oauth_token=self._oauth_token, path="clips", resource=Clip, params=params, ) else: return APIGet( client_id=self._client_id, oauth_token=self._oauth_token, path="clips", resource=Clip, params=params, ).fetch()
def get_users(self, ids=[], logins=[]): if len(ids) == 0 and len(logins) == 0: raise TwitchAttributeException( 'at least one id or login must be provided.') if (len(ids) + len(logins)) > 100: raise TwitchAttributeException( 'Maximum number of objects to return is 100') params = {'id': ids, 'login': logins} return APIGet(client_id=self._client_id, oauth_token=self._oauth_token, path='users', resource=User, params=params).fetch()
def get_games(self, game_ids=None, names=None): if game_ids and len(game_ids) > 100: raise TwitchAttributeException("Maximum of 100 Game IDs can be supplied") if names and len(names) > 100: raise TwitchAttributeException("Maximum of 100 Game names can be supplied") params = { "id": game_ids, "name": names, } return APIGet( client_id=self._client_id, oauth_token=self._oauth_token, path="games", resource=Game, params=params, ).fetch()
def get_games(self, game_ids=None, names=None): if game_ids and len(game_ids) > 100: raise TwitchAttributeException( 'Maximum of 100 Game IDs can be supplied') if names and len(names) > 100: raise TwitchAttributeException( 'Maximum of 100 Game names can be supplied') params = { 'id': game_ids, 'name': names, } return APIGet(client_id=self._client_id, oauth_token=self._oauth_token, path='games', resource=Game, params=params).fetch()
def get_clips(self, broadcaster_id=None, game_id=None, clip_ids=None, after=None, before=None, page_size=20): if not broadcaster_id and not clip_ids and not game_id: raise TwitchAttributeException( 'At least one of the following parameters must be provided ' '[broadcaster_id, clip_ids, game_id]') if clip_ids and len(clip_ids) > 100: raise TwitchAttributeException( 'Maximum of 100 Clip IDs can be supplied') if page_size > 100: raise TwitchAttributeException( 'Maximum number of objects to return is 100') params = { 'broadcaster_id': broadcaster_id, 'game_id': game_id, 'id': clip_ids, 'after': after, 'before': before, } if broadcaster_id or game_id: params['first'] = page_size return APICursor(client_id=self._client_id, oauth_token=self._oauth_token, path='clips', resource=Clip, params=params) else: return APIGet(client_id=self._client_id, oauth_token=self._oauth_token, path='clips', resource=Clip, params=params).fetch()
def get_videos( self, video_ids=None, user_id=None, game_id=None, after=None, before=None, page_size=20, language=None, period=PERIOD_ALL, sort=VIDEO_SORT_TIME, video_type=VIDEO_TYPE_ALL, ): if video_ids and len(video_ids) > 100: raise TwitchAttributeException("Maximum of 100 Video IDs can be supplied") params = { "id": video_ids, "user_id": user_id, "game_id": game_id, } if user_id or game_id: if page_size > 100: raise TwitchAttributeException( "Maximum number of objects to return is 100" ) if period not in PERIODS: raise TwitchAttributeException( "Invalid value for period. Valid values are {}".format(PERIODS) ) if sort not in VIDEO_SORTS: raise TwitchAttributeException( "Invalid value for sort. Valid values are {}".format(VIDEO_SORTS) ) if video_type not in VIDEO_TYPES: raise TwitchAttributeException( "Invalid value for video_type. Valid values are {}".format( VIDEO_TYPES ) ) params["after"] = after params["before"] = before params["first"] = page_size params["language"] = language params["period"] = period params["sort"] = sort params["type"] = video_type return APICursor( client_id=self._client_id, oauth_token=self._oauth_token, path="videos", resource=Video, params=params, ) else: return APIGet( client_id=self._client_id, oauth_token=self._oauth_token, path="videos", resource=Video, params=params, ).fetch()