def set_community(channel_id, community_id): log.deprecated_query('channels.set_community', 'channels.set_communities') 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
def get_app_access_token(self, scope=list()): q = Qry('token', method=methods.POST) q.add_param('client_id', self.client_id) q.add_param('client_secret', self.client_secret) q.add_param('grant_type', 'client_credentials') q.add_param('scope', ' '.join(scope)) return q
def report_violation(community_id, channel_id): 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
def prepare_token_uri(self, scope=list()): q = Qry('token') q.add_param('client_id', self.client_id) q.add_param('client_secret', self.client_secret) q.add_param('grant_type', 'client_credentials') q.add_param('scope', ' '.join(scope)) return '?'.join([q.url, urlencode(q.params)])
def get_posts(channel_id, limit=10, cursor='MA==', comments=5): q = Qry('feed/{channel_id}/posts') q.add_urlkw(keys.CHANNEL_ID, channel_id) q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==') q.add_param(keys.COMMENTS, comments, 5) return q
def get_top(after='MA==', before='MA==', first=20, use_app_token=False): q = Qry('games/top', 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, first, 20) return q
def by_channel(name, limit=25, offset=0, direction=Direction.DESC): q = Qry('channels/{channel}/follows') q.add_urlkw(keys.CHANNEL, name) q.add_param(keys.LIMIT, limit, 25) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.DIRECTION, direction, Direction.DESC) return q
def get_followed(stream_type=StreamType.LIVE, limit=25, offset=0): q = Qry('streams/followed') q.add_param(keys.STREAM_TYPE, StreamType.validate(stream_type), StreamType.LIVE) q.add_param(keys.LIMIT, limit, 25) q.add_param(keys.OFFSET, offset, 0) return q
def get_comments(channel_id, post_id, limit=10, cursor='MA=='): q = Qry('feed/{channel_id}/posts/{post_id}/comments') q.add_urlkw(keys.CHANNEL_ID, channel_id) q.add_urlkw(keys.POST_ID, post_id) q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==') return q
def streams(query, limit=25, offset=0, hls=Boolean.FALSE): q = Qry('search/streams') q.add_param(keys.QUERY, query) q.add_param(keys.LIMIT, limit, 25) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.HLS, hls, Boolean.FALSE) return q
def delete_comment_reaction(channel_id, post_id, comment_id, emote_id): q = Qry('feed/{channel_id}/posts/{post_id}/comments/{comment_id}/reactions', method=methods.DELETE) q.add_urlkw(keys.CHANNEL_ID, channel_id) q.add_urlkw(keys.POST_ID, post_id) q.add_urlkw(keys.COMMENT_ID, comment_id) q.add_param(keys.EMOTE_ID, emote_id) return q
def get_subscribers(channel_id, limit=25, offset=0, direction=Direction.ASC): q = Qry('channels/{channel_id}/subscriptions') q.add_urlkw(keys.CHANNEL_ID, channel_id) q.add_param(keys.LIMIT, limit, 25) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.DIRECTION, direction, Direction.DESC) return q
def top(limit=10, offset=0, game=None, period=Period.WEEK): q = Qry('videos/top') q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.GAME, game) q.add_param(keys.PERIOD, Period.validate(period), Period.WEEK) return q
def get_top(limit=10, offset=0, game=None, period=Period.WEEK, broadcast_type=BroadcastType.HIGHLIGHT): q = Qry('videos/top', use_token=False) q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.GAME, game) q.add_param(keys.PERIOD, Period.validate(period), Period.WEEK) q.add_param(keys.BROADCAST_TYPE, BroadcastType.validate(broadcast_type)) return q
def all(game=None, channel=None, limit=25, offset=0, client_id=None): q = Qry('streams') q.add_param(keys.GAME, game) q.add_param(keys.CHANNEL, channel) q.add_param(keys.LIMIT, limit, 25) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.CLIENT_ID, client_id) return q
def follow_channel(user_id, channel_id, notifications=Boolean.FALSE): q = Qry('users/{user_id}/follows/channels/{channel_id}', method=methods.PUT) q.add_urlkw(keys.USER_ID, user_id) q.add_urlkw(keys.CHANNEL_ID, channel_id) q.add_data(keys.NOTIFICATIONS, Boolean.validate(notifications), Boolean.FALSE) return q
def add_timeout(community_id, user_id, duration=1, reason=None): 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) q.add_data(keys.DURATION, duration) q.add_data(keys.REASON, reason) return q
def get_collections(channel_id, limit=10, cursor='MA==', containing_item=None): q = Qry('channels/{channel_id}/collections', use_token=False) q.add_urlkw(keys.CHANNEL_ID, channel_id) q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==') q.add_param(keys.CONTAINING_ITEM, containing_item, None) # 'video:<video_id>' return q
def games(search_query, live=Boolean.FALSE): q = Qry('search/games') q.add_param(keys.QUERY, search_query) q.add_param( keys.TYPE, 'suggest') # 'type' can currently only be suggest, so it is hardcoded q.add_param(keys.LIVE, live, Boolean.FALSE) return q
def by_channel(name, limit=10, offset=0, broadcasts=Boolean.FALSE, hls=Boolean.FALSE): q = Qry('channels/{channel}/videos') q.add_urlkw(keys.CHANNEL, name) q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.BROADCASTS, Boolean.validate(broadcasts), Boolean.FALSE) q.add_param(keys.HLS, Boolean.validate(hls), Boolean.FALSE) return q
def create(channel_id, title, description=None, game=None, language=None, tag_list=None): q = Qry('videos/', method=methods.POST) q.add_param(keys.CHANNEL_ID, channel_id) q.add_param(keys.TITLE, title) q.add_param(keys.DESCRIPTION, description) q.add_param(keys.GAME, game) if language is not None: q.add_param(keys.LANGUAGE, Language.validate(language)) q.add_param(keys.TAG_LIST, tag_list) return q
def update(video_id, title=None, description=None, game=None, language=None, tag_list=None): q = Qry('videos/{video_id}', method=methods.PUT) q.add_urlkw(keys.VIDEO_ID, video_id) q.add_param(keys.TITLE, title) q.add_param(keys.DESCRIPTION, description) q.add_param(keys.GAME, game) if language is not None: q.add_param(keys.LANGUAGE, Language.validate(language)) q.add_param(keys.TAG_LIST, tag_list) return q
def get_followed(trending=Boolean.FALSE, language=Language.ALL, cursor='MA==', limit=10): q = Qry('clips/followed') q.add_param(keys.TRENDING, Boolean.validate(trending), Boolean.FALSE) q.add_param(keys.LANGUAGE, Language.validate(language), Language.ALL) q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==') return q
def update(community_id, summary=None, description=None, rules=None, email=None): q = Qry('communities/{community_id}', method=methods.PUT) q.add_urlkw(keys.COMMUNITY_ID, community_id) q.add_data(keys.SUMMARY, summary) q.add_data(keys.DESCRIPTION, description) q.add_data(keys.RULES, rules) q.add_data(keys.EMAIL, email) return q
def get_follows(user_id, limit=25, offset=0, direction=Direction.DESC, sort_by=SortBy.CREATED_AT): q = Qry('users/{user_id}/follows/channels') q.add_urlkw(keys.USER_ID, user_id) q.add_param(keys.LIMIT, limit, 25) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.DIRECTION, direction, Direction.DESC) q.add_param(keys.SORT_BY, sort_by, SortBy.CREATED_AT) return q
def get_followers(channel_id, limit=25, offset=0, cursor='MA==', direction=Direction.DESC): q = Qry('channels/{channel_id}/follows') q.add_urlkw(keys.CHANNEL_ID, channel_id) q.add_param(keys.LIMIT, limit, 25) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==') q.add_param(keys.DIRECTION, direction, Direction.DESC) return q
def prepare_request_uri(self, redirect_uri='http://localhost:3000/', scope=list(), force_verify=False, state=''): q = Qry('authorize') q.add_param('response_type', 'token') q.add_param('client_id', self.client_id) q.add_param('redirect_uri', redirect_uri) q.add_param('scope', ' '.join(scope)) q.add_param('force_verify', str(force_verify).lower()) q.add_param('state', state) return '?'.join([q.url, urlencode(q.params)])
def get_all(game=None, channel_ids=None, community_id=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) if platform == Platform.XBOX_ONE: q.add_param(keys.XBOX_HEARTBEAT, Boolean.TRUE) elif platform == Platform.PS4: q.add_param(keys.SCE_PLATFORM, 'PS4') q.add_param(keys.LIMIT, limit, 25) q.add_param(keys.OFFSET, offset, 0) return q
def get_videos(channel_id, limit=10, offset=0, broadcast_type=BroadcastType.HIGHLIGHT, hls=Boolean.FALSE, sort_by=VideoSort.TIME, language=Language.ALL): q = Qry('channels/{id}/videos') q.add_urlkw(keys.ID, channel_id) q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.OFFSET, offset, 0) q.add_param(keys.BROADCAST_TYPE, BroadcastType.validate(broadcast_type)) q.add_param(keys.SORT, VideoSort.validate(sort_by), VideoSort.TIME) q.add_param(keys.LANGUAGE, Language.validate(language), Language.ALL) q.add_param(keys.HLS, Boolean.validate(hls), Boolean.FALSE) return q
def get_top(channels=None, games=None, period=ClipPeriod.WEEK, trending=Boolean.FALSE, language=Language.ALL, cursor='MA==', limit=10): q = Qry('clips/top') q.add_param(keys.CHANNEL, channels, None) q.add_param(keys.GAME, games, None) q.add_param(keys.PERIOD, ClipPeriod.validate(period), ClipPeriod.WEEK) q.add_param(keys.TRENDING, Boolean.validate(trending), Boolean.FALSE) q.add_param(keys.LANGUAGE, Language.validate(language), Language.ALL) q.add_param(keys.LIMIT, limit, 10) q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==') return q