# Path: src/moviesapp/exceptions.py
# class MovieNotInDb(Exception):
#     """
#     Movie is not in DB.
# 
#     It means the movie does not have an IMDB id.
#     """
# 
# Path: src/moviesapp/models.py
# def get_poster_url(size, poster):
#     if size == "small":
#         poster_size = settings.POSTER_SIZE_SMALL
#         no_image_url = settings.NO_POSTER_SMALL_IMAGE_URL
#     elif size == "normal":
#         poster_size = settings.POSTER_SIZE_NORMAL
#         no_image_url = settings.NO_POSTER_NORMAL_IMAGE_URL
#     elif size == "big":
#         poster_size = settings.POSTER_SIZE_BIG
#         no_image_url = None  # is not used anywhere
#     if poster is not None:
#         return settings.POSTER_BASE_URL + poster_size + "/" + poster
#     return no_image_url


from datetime import datetime
from operator import itemgetter
from babel.dates import format_date
from django.conf import settings
from .exceptions import MovieNotInDb
from .models import get_poster_url
import tmdbsimple
                movies = filter_movies_only(person.cast)
            else:
                movies = filter_movies_only(person.crew)
                movies = [m for m in movies if m["job"] == "Director"]
        return movies

    movies_data = get_data(query, search_type)
    movies = []
    i = 0
    if movies_data:
        user_movies_tmdb_ids = user.get_records().values_list("movie__tmdb_id", flat=True)
        for movie in movies_data:
            tmdb_id = movie["id"]
            i += 1
            if i > settings.MAX_RESULTS:
                break
            if tmdb_id in user_movies_tmdb_ids:
                continue
            poster = get_poster_from_tmdb(movie["poster_path"])
            # Skip unpopular movies if this option is enabled.
            if search_type == "movie" and options["popularOnly"] and not is_popular_movie(movie):
                continue

            movie = {
                "id": tmdb_id,
                "tmdbLink": f"{settings.TMDB_MOVIE_BASE_URL}{tmdb_id}",
                "elementId": f"movie{tmdb_id}",
                "releaseDate": movie.get("release_date"),
                "title": movie["title"],
                "poster": get_poster_url("small", poster),

# Path: src/moviesapp/exceptions.py
# class MovieNotInDb(Exception):
#     """
#     Movie is not in DB.
# 
#     It means the movie does not have an IMDB id.
#     """
# 
# Path: src/moviesapp/models.py
# def get_poster_url(size, poster):
#     if size == "small":
#         poster_size = settings.POSTER_SIZE_SMALL
#         no_image_url = settings.NO_POSTER_SMALL_IMAGE_URL
#     elif size == "normal":
#         poster_size = settings.POSTER_SIZE_NORMAL
#         no_image_url = settings.NO_POSTER_NORMAL_IMAGE_URL
#     elif size == "big":
#         poster_size = settings.POSTER_SIZE_BIG
#         no_image_url = None  # is not used anywhere
#     if poster is not None:
#         return settings.POSTER_BASE_URL + poster_size + "/" + poster
#     return no_image_url


# Path: src/moviesapp/tmdb.py
from datetime import datetime
from operator import itemgetter
from babel.dates import format_date
from django.conf import settings
from .exceptions import MovieNotInDb
from .models import get_poster_url
import tmdbsimple

                movies = filter_movies_only(person.cast)
            else:
                movies = filter_movies_only(person.crew)
                movies = [m for m in movies if m["job"] == "Director"]
        return movies

    movies_data = get_data(query, search_type)
    movies = []
    i = 0
    if movies_data:
        user_movies_tmdb_ids = user.get_records().values_list("movie__tmdb_id", flat=True)
        for movie in movies_data:
            tmdb_id = movie["id"]
            i += 1
            if i > settings.MAX_RESULTS:
                break
            if tmdb_id in user_movies_tmdb_ids:
                continue
            poster = get_poster_from_tmdb(movie["poster_path"])
            # Skip unpopular movies if this option is enabled.
            if search_type == "movie" and options["popularOnly"] and not is_popular_movie(movie):
                continue

            movie = {
                "id": tmdb_id,
                "tmdbLink": f"{settings.TMDB_MOVIE_BASE_URL}{tmdb_id}",
                "elementId": f"movie{tmdb_id}",
                "releaseDate": movie.get("release_date"),
                "title": movie["title"],
                "poster": get_poster_url("small", poster),

                "poster2x": get_poster_url("normal", poster),