Esempio n. 1
0
def get_actor_data(actor_name):
    # Get actor data from IMDB API
    ia = IMDb()
    res = ia._search_person(actor_name, results=True)
    person_ID = res[0][0]
    found_name = ' '.join(res[0][1]['name'].split(',')[::-1]).strip(' ')
    if found_name.lower() != actor_name.lower():
        print('Titles do not exactly match: ', actor_name, found_name)
    person = ia.get_person(person_ID)
    if 'birth date' in person.data.keys():
        birthyear = int(person.data['birth date'].split('-')[0])
        age = datetime.today().year - birthyear
    else:
        birthyear = np.nan
        age = np.nan
    award_data = ia.get_person_awards(person_ID)['data']['awards']
    oscar_nominations = oscar_wins = 0
    for nom in award_data:
        if (nom['award'] == 'Academy Awards, USA') and \
                (nom['category'] in ['Best Performance by an Actress in a Leading Role',
                                     'Best Performance by an Actress in a Supporting Role',
                                     'Best Performance by an Actor in a Leading Role',
                                     'Best Performance by an Actor in a Supporting Role',
                                     'Best Actor in a Leading Role', 'Best Actor in a Supporting Role',
                                     'Best Actress in a Leading Role', 'Best Actress in a Supporting Role']):
            oscar_nominations += 1
            if 'result' in nom.keys():
                if nom['result'] == 'Winner':
                    oscar_wins += 1

    return age, birthyear, oscar_nominations, oscar_wins
Esempio n. 2
0
def get_director_data(director_name):
    # Get director data from IMDB API
    ia = IMDb()
    res = ia._search_person(director_name, results=True)
    person_ID = res[0][0]
    found_name = ' '.join(res[0][1]['name'].split(',')[::-1]).strip(' ')
    if found_name.lower() != director_name.lower():
        print('Titles do not exactly match: ', director_name, found_name)
    award_data = ia.get_person_awards(person_ID)['data']['awards']
    oscar_nominations = oscar_wins = 0
    for nom in award_data:
        if (nom['award'] == 'Academy Awards, USA') and \
                (nom['category'] in ['Best Director', 'Best Achievement in Directing']):
            oscar_nominations += 1
            if 'result' in nom.keys():
                if nom['result'] == 'Winner':
                    oscar_wins += 1

    return oscar_nominations, oscar_wins