'Search the IMDb akas server for the given title or name.'

def _searchIMDb(self, kind, ton, title_kind=None):

    if (not ton):
        return None
    ton = ton.strip('"')
    aSystem = IMDb('mobile')
    if (kind == 'tt'):
        searchFunct = aSystem.search_movie
        check = 'long    imdb    title'
    elif (kind == 'nm'):
        searchFunct = aSystem.search_person
        check = 'long    imdb    name'
    elif (kind == 'char'):
        searchFunct = aSystem.search_character
        check = 'long    imdb    name'
    elif (kind == 'co'):
        searchFunct = aSystem.search_company
        check = 'long    imdb    name'
    try:
        searchRes = searchFunct(ton)
    except IMDbError:
        return None
    if (len(searchRes) == 1):
        return searchRes[0].getID()
    title_only_matches = []
    for item in searchRes:
        if (item[check].strip('"') == ton):
            if ((kind != 'tt') or (title_kind == item['kind'])):
                return item.getID()
            elif (kind == 'tt'):
                title_only_matches.append(item.getID())
    if title_only_matches:
        if (len(title_only_matches) == 1):
            return title_only_matches[0]
        else:
            return title_only_matches
    return None
