import requests


def get_episode_id( series_id, airedSeason, airedEpisode, tvdb_token, verify = True ):
    """
    Returns the TVDB_ :py:class:`int` episode ID of an episode, given its TVDB_ series ID, season, and episode number. If cannot be found, then returns ``None``.

    :param int series_id: the TVDB_ database series ID.
    :param int airedSeason: the season number of the episode.
    :param int airedEpisode: the aired episode number, in the season.
    :param str tvdb_token: the TVDB_ API access token.
    :param bool verify: optional argument, whether to verify SSL connections. Default is ``True``.
    
    :returns: the :py:class:`int` TVDB_ episode ID if found, otherwise ``None``.
    :rtype: int
    """
    params = { 'page' : 1,
               'airedSeason' : '%d' % airedSeason,
               'airedEpisode' : '%d' % airedEpisode }
    headers = { 'Content-Type' : 'application/json',
                'Authorization' : 'Bearer %s' % tvdb_token }
    response = requests.get( 'https://api.thetvdb.com/series/%d/episodes/query' % series_id,
                             params = params, headers = headers, verify = verify )
    if response.status_code != 200: return None
    data = max( response.json( )[ 'data' ] )
    return data[ 'id' ]