feat: add imdb_id parameter to update movie and show methods

This commit is contained in:
maxid
2025-12-23 20:29:51 +01:00
parent ff3797e1c4
commit 9c6676f1f3
4 changed files with 13 additions and 0 deletions

View File

@@ -435,10 +435,12 @@ class MovieRepository:
name: str | None = None,
overview: str | None = None,
year: int | None = None,
imdb_id: str | None = None,
) -> MovieSchema:
"""
Update attributes of an existing movie.
:param imdb_id: The new IMDb ID for the movie.
:param movie_id: The ID of the movie to update.
:param name: The new name for the movie.
:param overview: The new overview for the movie.
@@ -459,6 +461,9 @@ class MovieRepository:
if year is not None and db_movie.year != year:
db_movie.year = year
updated = True
if imdb_id is not None and db_movie.imdb_id != imdb_id:
db_movie.imdb_id = imdb_id
updated = True
if updated:
self.db.commit()

View File

@@ -719,6 +719,7 @@ class MovieService:
name=fresh_movie_data.name,
overview=fresh_movie_data.overview,
year=fresh_movie_data.year,
imdb_id=fresh_movie_data.imdb_id,
)
updated_movie = self.movie_repository.get_movie_by_id(movie_id=db_movie.id)

View File

@@ -643,10 +643,13 @@ class TvRepository:
year: int | None = None,
ended: bool | None = None,
continuous_download: bool | None = None,
imdb_id: str | None = None,
) -> ShowSchema: # Removed poster_url from params
"""
Update attributes of an existing show.
:param imdb_id: The new IMDb ID for the show.
:param continuous_download: The new continuous download status for the show.
:param show_id: The ID of the show to update.
:param name: The new name for the show.
:param overview: The new overview for the show.
@@ -677,6 +680,9 @@ class TvRepository:
):
db_show.continuous_download = continuous_download
updated = True
if imdb_id is not None and db_show.imdb_id != imdb_id:
db_show.imdb_id = imdb_id
updated = True
if updated:
self.db.commit()
self.db.refresh(db_show)

View File

@@ -780,6 +780,7 @@ class TvService:
overview=fresh_show_data.overview,
year=fresh_show_data.year,
ended=fresh_show_data.ended,
imdb_id=fresh_show_data.imdb_id,
continuous_download=db_show.continuous_download
if fresh_show_data.ended is False
else False,