Esempio n. 1
0
def search_exists(search, select, repo: AbstractRepository):

    if select == "Genre":
        if Genre(search) in repo.get_genres():
            return True
        else:
            return False

    elif select == "Director":
        if Director(search) in repo.get_directors():
            return True
        else:
            return False

    elif select == "Actor":
        if Actor(search) in repo.get_actors():
            return True
        else:
            return False
def add_to_watchlist(movie_id: int, username: str, repo: AbstractRepository):

    if repo.get_user(username) is None:
        raise UnknownUserException

    if repo.get_movie(movie_id) is None:
        raise NonExistentMovieException

    repo.add_to_watchlist(repo.get_movie(movie_id), repo.get_user(username))
Esempio n. 3
0
def get_movie_by_a_rank(rank, repo: AbstractRepository):
    movie = repo.get_movie(rank)
    movie_dict = movie_to_dict(movie)
    prev_rank = next_rank = None
    if movie.rank == 1:
        prev_rank = None
        next_rank = 4
    elif movie.rank == 1000:
        prev_rank = 997
        next_rank = None
    elif 1 < movie.rank < 1000:
        prev_rank = movie.rank - 3
        next_rank = movie.rank + 3

    return movie_dict, prev_rank, next_rank
Esempio n. 4
0
def get_movies_by_director(repo: AbstractRepository, director: str):
    res = repo.get_movie_by_director(director)
    return res
Esempio n. 5
0
def get_movies_by_genre(repo: AbstractRepository, genre: str):
    res = repo.get_movie_by_genre(genre)
    return res
Esempio n. 6
0
def get_movies_by_actor(repo: AbstractRepository, name: str):
    res = repo.get_movie_by_actor(name)
    return res
Esempio n. 7
0
def get_all_movies(repo: AbstractRepository):
    res = repo.get_all_movies()
    return res
Esempio n. 8
0
def filter_movies(actor_name: str, director_name: str, genre_name: str, repo: AbstractRepository):
    movie_ids = repo.filter_movies(actor_name, director_name, genre_name)
    return movie_ids
Esempio n. 9
0
def get_last_movie(repo: AbstractRepository):

    movie = repo.get_last_movie()
    return movie_to_dict(movie)
Esempio n. 10
0
def get_movie_ids_for_director(director_name, repo: AbstractRepository):
    director_ids = repo.get_movie_ids_for_director(director_name)

    return director_ids
Esempio n. 11
0
def get_director_names(repo: AbstractRepository):
    directors = repo.get_directors()
    director_names = [director.director_full_name for director in directors]

    return director_names
Esempio n. 12
0
def movies_on_page(current_rank, repo: AbstractRepository):
    movie_list = [current_rank, current_rank + 1, current_rank + 2]

    movies = repo.get_movies_by_rank(movie_list)

    return movies_to_dict(movies)
Esempio n. 13
0
def get_movies_ranks_for_genre(genre_name, repo: AbstractRepository):
    movie_ranks = repo.get_movie_ranks_for_genre(genre_name)

    return movie_ranks
Esempio n. 14
0
def get_movies_by_rank(rank_list, repo: AbstractRepository):
    movies = repo.get_movies_by_rank(rank_list)
    movies_as_dict = movies_to_dict(movies)

    return movies_as_dict
Esempio n. 15
0
def get_movie_by_rank(repo: AbstractRepository, rank: int):
    res = repo.get_movie_by_rank(rank)
    return res
Esempio n. 16
0
def get_actor_names(repo: AbstractRepository):
    actors = repo.get_actors()
    actor_names = [actor.actor_full_name for actor in actors]

    return actor_names
Esempio n. 17
0
def get_movie_ids_for_actor(actor_name, repo: AbstractRepository):
    movie_ids = repo.get_movie_ids_for_actor(actor_name)

    return movie_ids
def get_genre_names(repo: AbstractRepository):
    genres = repo.get_genres()
    genre_names = [genre.genre_name for genre in genres]

    return genre_names
Esempio n. 19
0
def get_movie_ids_for_genre(genre_name, repo: AbstractRepository):
    genre_ids = repo.get_movie_ids_for_genre(genre_name)

    return genre_ids
Esempio n. 20
0
def get_user(username: str, repository: AbstractRepository):
    user = repository.get_user(username)
    if user is None:
        raise UnknownUserException

    return user_to_dict(user)
Esempio n. 21
0
def get_watchlist(username: str, repo: AbstractRepository):
    user = repo.get_user(username)
    if user is None:
        raise UnknownUserException

    return user.watchlist
Esempio n. 22
0
def get_all_movie_ids(repo: AbstractRepository):
    movie_ids = repo.get_all_movie_ids()
    return movie_ids