def movie(sentence):
    sentence = sentence.lower()
    movie_list = []
    m = Movie()
    parental_rating(sentence, m)
    genre(sentence, m)
    directors(sentence, m)
    stars(sentence, m)

    p = m.get_parental_rating() == ''
    g = m.get_genre() == []
    d = m.get_directors() == []
    s = m.get_stars() == []

    for movie in allmovies:
        parental_rating_pass = p
        genre_pass = g
        director_pass = d
        stars_pass = s
        if not parental_rating_pass:
            parental_rating_pass = m.get_parental_rating() == movie[2]

        if not genre_pass:
            for m_genre in m.get_genre():
                genre_pass = m_genre in movie[4].lower()

        if not director_pass:
            i = 1
            if movie[6].lower() != '':
                temp = movie[6].lower().split(', ')
                for actor in temp:
                    director_pass = actor in m.get_directors()[i-1].lower()
                    if director_pass:
                        break;
                while i < len(m.get_directors()):
                    temp1 = False
                    temp2 = False
                    for actor in temp:
                        temp1 = actor in m.get_directors()[i-1].lower()
                        if temp1:
                            break;
                    for actor in temp:
                        temp2 = actor in m.get_directors()[i+1].lower()
                        if temp2:
                            break;
                    if m.get_directors()[i].lower() == 'and':
                        director_pass = temp1 and temp2
                    elif m.get_directors()[i].lower() == 'or':
                        director_pass = temp1 or temp2
                    if director_pass and i + 2 < len(m.get_directors()) and m.get_directors()[i + 2].lower() == 'or':
                        break;
                    i += 2

        if not stars_pass:
            i = 1
            if movie[8].lower() != '':
                temp = movie[8].lower().split(', ')
                for actor in temp:
                    stars_pass = actor in m.get_stars()[i-1].lower()
                    if stars_pass:
                        break;
                while i < len(m.get_stars()):
                    temp1 = False
                    temp2 = False
                    for actor in temp:
                        temp1 = actor in m.get_stars()[i-1].lower()
                        if temp1:
                            break;
                    for actor in temp:
                        temp2 = actor in m.get_stars()[i+1].lower()
                        if temp2:
                            break;
                    if m.get_stars()[i].lower() == 'and':
                        stars_pass = temp1 and temp2
                    elif m.get_stars()[i].lower() == 'or':
                        stars_pass = temp1 or temp2
                    if stars_pass and i + 2 < len(m.get_stars()) and m.get_stars()[i + 2].lower() == 'or':
                        break;
                    i += 2

        if parental_rating_pass and genre_pass and director_pass and stars_pass:
            if p and g and d and s:
                return check_product([], sentence, p, g, d, s)
            movie_list.append(movie[1])
    return check_product(movie_list, sentence, p, g, d, s)
def movie(sentence):
    sentence = sentence.lower()
    movie_list = []
    m = Movie()
    parental_rating(sentence, m)
    genre(sentence, m)
    directors(sentence, m)
    stars(sentence, m)

    p = m.get_parental_rating() == ''
    g = m.get_genre() == []
    d = m.get_directors() == []
    s = m.get_stars() == []

    for movie in allmovies:
        parental_rating_pass = p
        genre_pass = g
        director_pass = d
        stars_pass = s
        if not parental_rating_pass:
            parental_rating_pass = m.get_parental_rating() == movie[2]

        if not genre_pass:
            for m_genre in m.get_genre():
                genre_pass = m_genre in movie[4].lower()

        if not director_pass:
            i = 1
            if movie[6].lower() != '':
                temp = movie[6].lower().split(', ')
                for actor in temp:
                    director_pass = actor in m.get_directors()[i - 1].lower()
                    if director_pass:
                        break
                while i < len(m.get_directors()):
                    temp1 = False
                    temp2 = False
                    for actor in temp:
                        temp1 = actor in m.get_directors()[i - 1].lower()
                        if temp1:
                            break
                    for actor in temp:
                        temp2 = actor in m.get_directors()[i + 1].lower()
                        if temp2:
                            break
                    if m.get_directors()[i].lower() == 'and':
                        director_pass = temp1 and temp2
                    elif m.get_directors()[i].lower() == 'or':
                        director_pass = temp1 or temp2
                    if director_pass and i + 2 < len(m.get_directors(
                    )) and m.get_directors()[i + 2].lower() == 'or':
                        break
                    i += 2

        if not stars_pass:
            i = 1
            if movie[8].lower() != '':
                temp = movie[8].lower().split(', ')
                for actor in temp:
                    stars_pass = actor in m.get_stars()[i - 1].lower()
                    if stars_pass:
                        break
                while i < len(m.get_stars()):
                    temp1 = False
                    temp2 = False
                    for actor in temp:
                        temp1 = actor in m.get_stars()[i - 1].lower()
                        if temp1:
                            break
                    for actor in temp:
                        temp2 = actor in m.get_stars()[i + 1].lower()
                        if temp2:
                            break
                    if m.get_stars()[i].lower() == 'and':
                        stars_pass = temp1 and temp2
                    elif m.get_stars()[i].lower() == 'or':
                        stars_pass = temp1 or temp2
                    if stars_pass and i + 2 < len(m.get_stars(
                    )) and m.get_stars()[i + 2].lower() == 'or':
                        break
                    i += 2

        if parental_rating_pass and genre_pass and director_pass and stars_pass:
            if p and g and d and s:
                return check_product([], sentence, p, g, d, s)
            movie_list.append(movie[1])
    return check_product(movie_list, sentence, p, g, d, s)