def search_id(id, medium, credentials):
    """Grabs the [medium] with the given id from MyAnimeList as a [medium]
    object.
    :param id     The id of the [medium].
    :param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
    :return The [medium] object with id requested, or None if no such [medium]
            exists.
    :raise ValueError For bad arguments.
    """
    helpers.check_creds(credentials, header)
    if id <= 0 or not float(id).is_integer():
        raise ValueError(constants.INVALID_ID)
    scrape_query = helpers.get_scrape_url(id, medium)
    if scrape_query is None:
        raise ValueError(constants.INVALID_MEDIUM)
    search_resp = requests.get(scrape_query, headers=header)
    scrape_soup = BeautifulSoup(search_resp.text, 'html.parser')
    #inspect element on an anime page, you'll see where this scrape is
    #coming from.
    query = scrape_soup.find('span', {'itemprop':'name'})
    if query is None:
        return helpers.reschedule(search_id, constants.DEFAULT_WAIT_SECS, id,
                                  medium)
    matches = search(query.text, medium, credentials)
    index = [match.id for match in matches].index(str(id))
    if index != -1:
        return matches[index]
    else:
        return None
def search_id ( id , medium , credentials ) : helpers . check_creds ( credentials , header ) if id <= 0 or not float ( id ) . is_integer ( ) : raise ValueError ( constants . INVALID_ID ) scrape_query = helpers . get_scrape_url ( id , medium ) if scrape_query is None : raise ValueError ( constants . INVALID_MEDIUM ) search_resp = requests . get ( scrape_query , headers = header ) scrape_soup = BeautifulSoup ( search_resp . text , 'html.parser' ) query = scrape_soup . find ( 'span' , { 'itemprop' : 'name' } ) if query is None : return helpers . reschedule ( search_id , constants . DEFAULT_WAIT_SECS , id , medium ) matches = search ( query . text , medium , credentials ) index = [ match . id for match in matches ] . index ( str ( id ) ) if index != - 1 : return matches [ index ] else : return None
Grabs the [medium] with the given id from MyAnimeList as a [medium]
    object.
    :param id     The id of the [medium].
    :param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
    :return The [medium] object with id requested, or None if no such [medium]
            exists.
    :raise ValueError For bad arguments.