Пример #1
0
    def streams(self, query, limit=25, offset=0, hls=None):
        if limit > 100:
            raise TwitchAttributeException(
                "Maximum number of objects returned in one request is 100")

        params = {"query": query, "limit": limit, "offset": offset, "hls": hls}
        response = self._request_get("search/streams", params=params)
        return [Stream.construct_from(x) for x in response["streams"] or []]
Пример #2
0
    def streams(self, query, limit=25, offset=0, hls=None):
        if limit > 100:
            raise TwitchAttributeException(
                'Maximum number of objects returned in one request is 100')

        params = {'query': query, 'limit': limit, 'offset': offset, 'hls': hls}
        response = self._request_get('search/streams', params=params)
        return [Stream.construct_from(x) for x in response['streams'] or []]
Пример #3
0
    def get_followed(self, stream_type=STREAM_TYPE_LIVE, limit=25, offset=0):
        if stream_type not in STREAM_TYPES:
            raise TwitchAttributeException(
                'Stream type is not valid. Valid values are %s' % STREAM_TYPES)
        if limit > 100:
            raise TwitchAttributeException(
                'Maximum number of objects returned in one request is 100')

        params = {'stream_type': stream_type, 'limit': limit, 'offset': offset}
        response = self._request_get('streams/followed', params=params)
        return [Stream.construct_from(x) for x in response['streams']]
Пример #4
0
    def get_followed(self, stream_type=STREAM_TYPE_LIVE, limit=25, offset=0):
        if stream_type not in STREAM_TYPES:
            raise TwitchAttributeException(
                "Stream type is not valid. Valid values are {}".format(
                    STREAM_TYPES))
        if limit > 100:
            raise TwitchAttributeException(
                "Maximum number of objects returned in one request is 100")

        params = {"stream_type": stream_type, "limit": limit, "offset": offset}
        response = self._request_get("streams/followed", params=params)
        return [Stream.construct_from(x) for x in response["streams"]]
Пример #5
0
    def get_stream_by_user(self, channel_id, stream_type=STREAM_TYPE_LIVE):
        if stream_type not in STREAM_TYPES:
            raise TwitchAttributeException(
                'Stream type is not valid. Valid values are %s' % STREAM_TYPES)

        params = {
            'stream_type': stream_type,
        }
        response = self._request_get('streams/%s' % channel_id, params=params)

        if not response['stream']:
            return None
        return Stream.construct_from(response['stream'])
Пример #6
0
    def get_stream_by_user(self, channel_id, stream_type=STREAM_TYPE_LIVE):
        if stream_type not in STREAM_TYPES:
            raise TwitchAttributeException(
                "Stream type is not valid. Valid values are {}".format(STREAM_TYPES)
            )

        params = {
            "stream_type": stream_type,
        }
        response = self._request_get("streams/{}".format(channel_id), params=params)

        if not response["stream"]:
            return None
        return Stream.construct_from(response["stream"])
Пример #7
0
    def get_live_streams(self,
                         channel=None,
                         game=None,
                         language=None,
                         stream_type=STREAM_TYPE_LIVE,
                         limit=25,
                         offset=0):
        if limit > 100:
            raise TwitchAttributeException(
                'Maximum number of objects returned in one request is 100')

        params = {'stream_type': stream_type, 'limit': limit, 'offset': offset}
        if channel is not None:
            params['channel'] = channel
        if game is not None:
            params['game'] = game
        if language is not None:
            params['language'] = language
        response = self._request_get('streams', params=params)
        return [Stream.construct_from(x) for x in response['streams']]
Пример #8
0
    def get_live_streams(
        self,
        channel=None,
        game=None,
        language=None,
        stream_type=STREAM_TYPE_LIVE,
        limit=25,
        offset=0,
    ):
        if limit > 100:
            raise TwitchAttributeException(
                "Maximum number of objects returned in one request is 100")

        params = {"stream_type": stream_type, "limit": limit, "offset": offset}
        if channel is not None:
            params["channel"] = channel
        if game is not None:
            params["game"] = game
        if language is not None:
            params["language"] = language
        response = self._request_get("streams", params=params)
        return [Stream.construct_from(x) for x in response["streams"]]
Пример #9
0
    def get_streams_in_community(self, community_id):
        response = self._request_get(
            'streams?community_id={}'.format(community_id))

        return [Stream.construct_from(x) for x in response['streams']]