# 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
        return trailers

    def get_movie_data(tmdb_id, lang):
        tmdb = get_tmdb(lang=lang)
        return tmdb.Movies(tmdb_id)

    movie_data_en = get_movie_data(tmdb_id, "en")
    movie_info_en = movie_data_en.info()
    # We have to get all info in english first before we switch to russian or everything breaks.
    trailers_en = get_trailers(movie_data_en)
    movie_data_ru = get_movie_data(tmdb_id, "ru")
    movie_info_ru = movie_data_ru.info()
    trailers_ru = get_trailers(movie_data_ru)
    imdb_id = movie_info_en["imdb_id"]
    if imdb_id:
        return {
            "tmdb_id": tmdb_id,
            "imdb_id": imdb_id,
            "release_date": get_release_date(movie_info_en["release_date"]),
            "title_original": movie_info_en["original_title"],
            "poster_ru": get_poster_from_tmdb(movie_info_ru["poster_path"]),
            "poster_en": get_poster_from_tmdb(movie_info_en["poster_path"]),
            "homepage": movie_info_en["homepage"],
            "trailers_en": trailers_en,
            "trailers_ru": trailers_ru,
            "title_en": movie_info_en["title"],
            "title_ru": movie_info_ru["title"],
            "description_en": movie_info_en["overview"],
            "description_ru": movie_info_ru["overview"],
        }

# 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

        return trailers

    def get_movie_data(tmdb_id, lang):
        tmdb = get_tmdb(lang=lang)
        return tmdb.Movies(tmdb_id)

    movie_data_en = get_movie_data(tmdb_id, "en")
    movie_info_en = movie_data_en.info()
    # We have to get all info in english first before we switch to russian or everything breaks.
    trailers_en = get_trailers(movie_data_en)
    movie_data_ru = get_movie_data(tmdb_id, "ru")
    movie_info_ru = movie_data_ru.info()
    trailers_ru = get_trailers(movie_data_ru)
    imdb_id = movie_info_en["imdb_id"]
    if imdb_id:
        return {
            "tmdb_id": tmdb_id,
            "imdb_id": imdb_id,
            "release_date": get_release_date(movie_info_en["release_date"]),
            "title_original": movie_info_en["original_title"],
            "poster_ru": get_poster_from_tmdb(movie_info_ru["poster_path"]),
            "poster_en": get_poster_from_tmdb(movie_info_en["poster_path"]),
            "homepage": movie_info_en["homepage"],
            "trailers_en": trailers_en,
            "trailers_ru": trailers_ru,
            "title_en": movie_info_en["title"],
            "title_ru": movie_info_ru["title"],
            "description_en": movie_info_en["overview"],
            "description_ru": movie_info_ru["overview"],
        }

    raise MovieNotInDb(tmdb_id)