# Path: twitch/api/base.py
# class TwitchAPI(object):
#     """Twitch API client."""
# 
#     def __init__(self, client_id, oauth_token=None):
#         """Initialize the API."""
#         super(TwitchAPI, self).__init__()
#         self._client_id = client_id
#         self._oauth_token = oauth_token
#         self._initial_backoff, self._max_retries = backoff_config()
# 
#     def _get_request_headers(self):
#         """Prepare the headers for the requests."""
#         headers = {
#             "Accept": "application/vnd.twitchtv.v5+json",
#             "Client-ID": self._client_id,
#         }
# 
#         if self._oauth_token:
#             headers["Authorization"] = "OAuth {}".format(self._oauth_token)
# 
#         return headers
# 
#     def _request_get(self, path, params=None, json=True, url=BASE_URL):
#         """Perform a HTTP GET request."""
#         url = urljoin(url, path)
#         headers = self._get_request_headers()
# 
#         response = requests.get(url, params=params, headers=headers)
#         if response.status_code >= 500:
# 
#             backoff = self._initial_backoff
#             for _ in range(self._max_retries):
#                 time.sleep(backoff)
#                 backoff_response = requests.get(
#                     url, params=params, headers=headers, timeout=DEFAULT_TIMEOUT
#                 )
#                 if backoff_response.status_code < 500:
#                     response = backoff_response
#                     break
#                 backoff *= 2
# 
#         response.raise_for_status()
#         if json:
#             return response.json()
#         else:
#             return response
# 
#     def _request_post(self, path, data=None, params=None, url=BASE_URL):
#         """Perform a HTTP POST request.."""
#         url = urljoin(url, path)
# 
#         headers = self._get_request_headers()
# 
#         response = requests.post(
#             url, json=data, params=params, headers=headers, timeout=DEFAULT_TIMEOUT
#         )
#         response.raise_for_status()
#         if response.status_code == 200:
#             return response.json()
# 
#     def _request_put(self, path, data=None, params=None, url=BASE_URL):
#         """Perform a HTTP PUT request."""
#         url = urljoin(url, path)
# 
#         headers = self._get_request_headers()
#         response = requests.put(
#             url, json=data, params=params, headers=headers, timeout=DEFAULT_TIMEOUT
#         )
#         response.raise_for_status()
#         if response.status_code == 200:
#             return response.json()
# 
#     def _request_delete(self, path, params=None, url=BASE_URL):
#         """Perform a HTTP DELETE request."""
#         url = urljoin(url, path)
# 
#         headers = self._get_request_headers()
# 
#         response = requests.delete(
#             url, params=params, headers=headers, timeout=DEFAULT_TIMEOUT
#         )
#         response.raise_for_status()
#         if response.status_code == 200:
#             return response.json()
# 
# Path: twitch/constants.py
# BROADCAST_TYPE_HIGHLIGHT = "highlight"
# 
# BROADCAST_TYPES = [
#     BROADCAST_TYPE_ARCHIVE,
#     BROADCAST_TYPE_HIGHLIGHT,
#     BROADCAST_TYPE_UPLOAD,
#     BROADCAST_TYPE_ARCHIVE_UPLOAD,
#     BROADCAST_TYPE_ARCHIVE_HIGHLIGHT,
#     BROADCAST_TYPE_HIGHLIGHT_UPLOAD,
#     BROADCAST_TYPE_ALL,
# ]
# 
# DIRECTION_ASC = "asc"
# 
# DIRECTION_DESC = "desc"
# 
# DIRECTIONS = [DIRECTION_ASC, DIRECTION_DESC]
# 
# VIDEO_SORT_TIME = "time"
# 
# VIDEO_SORTS = [VIDEO_SORT_TIME, VIDEO_SORT_TRENDING, VIDEO_SORT_VIEWS]
# 
# Path: twitch/decorators.py
# def oauth_required(func):
#     def wrapper(*args, **kwargs):
#         if not args[0]._oauth_token:
#             raise TwitchAuthException("OAuth token required")
#         return func(*args, **kwargs)
# 
#     return wrapper
# 
# Path: twitch/exceptions.py
# class TwitchAttributeException(TwitchException):
#     pass
# 
# Path: twitch/resources.py
# class Channel(TwitchObject):
#     pass
# 
# class Community(TwitchObject):
#     pass
# 
# class Follow(TwitchObject):
#     pass
# 
# class Subscription(TwitchObject):
#     pass
# 
# class Team(TwitchObject):
#     pass
# 
# class User(TwitchObject):
#     pass
# 
# class Video(TwitchObject):
#     pass


from twitch.api.base import TwitchAPI
from twitch.constants import (
    BROADCAST_TYPE_HIGHLIGHT,
    BROADCAST_TYPES,
    DIRECTION_ASC,
    DIRECTION_DESC,
    DIRECTIONS,
    VIDEO_SORT_TIME,
    VIDEO_SORTS,
)
from twitch.decorators import oauth_required
from twitch.exceptions import TwitchAttributeException
from twitch.resources import Channel, Community, Follow, Subscription, Team, User, Video
        return [Team.construct_from(x) for x in response["teams"]]

    @oauth_required
    def get_subscribers(self, channel_id, limit=25, offset=0, direction=DIRECTION_ASC):
        if limit > 100:
            raise TwitchAttributeException(
                "Maximum number of objects returned in one request is 100"
            )
        if direction not in DIRECTIONS:
            raise TwitchAttributeException(
                "Direction is not valid. Valid values are {}".format(DIRECTIONS)
            )

        params = {"limit": limit, "offset": offset, "direction": direction}
        response = self._request_get(
            "channels/{}/subscriptions".format(channel_id), params=params
        )
        return [Subscription.construct_from(x) for x in response["subscriptions"]]

    def check_subscription_by_user(self, channel_id, user_id):
        response = self._request_get(
            "channels/{}/subscriptions/{}".format(channel_id, user_id)
        )
        return Subscription.construct_from(response)

    def get_videos(
        self,
        channel_id,
        limit=10,
        offset=0,

# Path: twitch/api/base.py
# class TwitchAPI(object):
#     """Twitch API client."""
# 
#     def __init__(self, client_id, oauth_token=None):
#         """Initialize the API."""
#         super(TwitchAPI, self).__init__()
#         self._client_id = client_id
#         self._oauth_token = oauth_token
#         self._initial_backoff, self._max_retries = backoff_config()
# 
#     def _get_request_headers(self):
#         """Prepare the headers for the requests."""
#         headers = {
#             "Accept": "application/vnd.twitchtv.v5+json",
#             "Client-ID": self._client_id,
#         }
# 
#         if self._oauth_token:
#             headers["Authorization"] = "OAuth {}".format(self._oauth_token)
# 
#         return headers
# 
#     def _request_get(self, path, params=None, json=True, url=BASE_URL):
#         """Perform a HTTP GET request."""
#         url = urljoin(url, path)
#         headers = self._get_request_headers()
# 
#         response = requests.get(url, params=params, headers=headers)
#         if response.status_code >= 500:
# 
#             backoff = self._initial_backoff
#             for _ in range(self._max_retries):
#                 time.sleep(backoff)
#                 backoff_response = requests.get(
#                     url, params=params, headers=headers, timeout=DEFAULT_TIMEOUT
#                 )
#                 if backoff_response.status_code < 500:
#                     response = backoff_response
#                     break
#                 backoff *= 2
# 
#         response.raise_for_status()
#         if json:
#             return response.json()
#         else:
#             return response
# 
#     def _request_post(self, path, data=None, params=None, url=BASE_URL):
#         """Perform a HTTP POST request.."""
#         url = urljoin(url, path)
# 
#         headers = self._get_request_headers()
# 
#         response = requests.post(
#             url, json=data, params=params, headers=headers, timeout=DEFAULT_TIMEOUT
#         )
#         response.raise_for_status()
#         if response.status_code == 200:
#             return response.json()
# 
#     def _request_put(self, path, data=None, params=None, url=BASE_URL):
#         """Perform a HTTP PUT request."""
#         url = urljoin(url, path)
# 
#         headers = self._get_request_headers()
#         response = requests.put(
#             url, json=data, params=params, headers=headers, timeout=DEFAULT_TIMEOUT
#         )
#         response.raise_for_status()
#         if response.status_code == 200:
#             return response.json()
# 
#     def _request_delete(self, path, params=None, url=BASE_URL):
#         """Perform a HTTP DELETE request."""
#         url = urljoin(url, path)
# 
#         headers = self._get_request_headers()
# 
#         response = requests.delete(
#             url, params=params, headers=headers, timeout=DEFAULT_TIMEOUT
#         )
#         response.raise_for_status()
#         if response.status_code == 200:
#             return response.json()
# 
# Path: twitch/constants.py
# BROADCAST_TYPE_HIGHLIGHT = "highlight"
# 
# BROADCAST_TYPES = [
#     BROADCAST_TYPE_ARCHIVE,
#     BROADCAST_TYPE_HIGHLIGHT,
#     BROADCAST_TYPE_UPLOAD,
#     BROADCAST_TYPE_ARCHIVE_UPLOAD,
#     BROADCAST_TYPE_ARCHIVE_HIGHLIGHT,
#     BROADCAST_TYPE_HIGHLIGHT_UPLOAD,
#     BROADCAST_TYPE_ALL,
# ]
# 
# DIRECTION_ASC = "asc"
# 
# DIRECTION_DESC = "desc"
# 
# DIRECTIONS = [DIRECTION_ASC, DIRECTION_DESC]
# 
# VIDEO_SORT_TIME = "time"
# 
# VIDEO_SORTS = [VIDEO_SORT_TIME, VIDEO_SORT_TRENDING, VIDEO_SORT_VIEWS]
# 
# Path: twitch/decorators.py
# def oauth_required(func):
#     def wrapper(*args, **kwargs):
#         if not args[0]._oauth_token:
#             raise TwitchAuthException("OAuth token required")
#         return func(*args, **kwargs)
# 
#     return wrapper
# 
# Path: twitch/exceptions.py
# class TwitchAttributeException(TwitchException):
#     pass
# 
# Path: twitch/resources.py
# class Channel(TwitchObject):
#     pass
# 
# class Community(TwitchObject):
#     pass
# 
# class Follow(TwitchObject):
#     pass
# 
# class Subscription(TwitchObject):
#     pass
# 
# class Team(TwitchObject):
#     pass
# 
# class User(TwitchObject):
#     pass
# 
# class Video(TwitchObject):
#     pass


# Path: twitch/api/channels.py
from twitch.api.base import TwitchAPI
from twitch.constants import (
    BROADCAST_TYPE_HIGHLIGHT,
    BROADCAST_TYPES,
    DIRECTION_ASC,
    DIRECTION_DESC,
    DIRECTIONS,
    VIDEO_SORT_TIME,
    VIDEO_SORTS,
)
from twitch.decorators import oauth_required
from twitch.exceptions import TwitchAttributeException
from twitch.resources import Channel, Community, Follow, Subscription, Team, User, Video

        return [Team.construct_from(x) for x in response["teams"]]

    @oauth_required
    def get_subscribers(self, channel_id, limit=25, offset=0, direction=DIRECTION_ASC):
        if limit > 100:
            raise TwitchAttributeException(
                "Maximum number of objects returned in one request is 100"
            )
        if direction not in DIRECTIONS:
            raise TwitchAttributeException(
                "Direction is not valid. Valid values are {}".format(DIRECTIONS)
            )

        params = {"limit": limit, "offset": offset, "direction": direction}
        response = self._request_get(
            "channels/{}/subscriptions".format(channel_id), params=params
        )
        return [Subscription.construct_from(x) for x in response["subscriptions"]]

    def check_subscription_by_user(self, channel_id, user_id):
        response = self._request_get(
            "channels/{}/subscriptions/{}".format(channel_id, user_id)
        )
        return Subscription.construct_from(response)

    def get_videos(
        self,
        channel_id,
        limit=10,
        offset=0,

        broadcast_type=BROADCAST_TYPE_HIGHLIGHT,