def search(name, year=None):
    if name is None or name == '':
        raise Exception

    if isinstance(name, unicode):
        name = name.encode('utf8')

    endpoint = TMDB_HOST + '/search/movie'
    payload = {'api_key': TMDB_API_KEY, 'query': urllib.quote_plus(str(name))}
    if year is not None:
        payload['year'] = year

    try:
        response = requests.get(endpoint, params=payload, timeout=5)
    except (requests.exceptions.Timeout, requests.exceptions.ConnectionError):
        raise Exception

    try:
        result = json.loads(response.text)
        return result['results']
    except __HOLE__:
        raise Exception
dataset/ETHPy150Open divijbindlish/movienamer/movienamer/tmdb.py/search