mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:13:24 +02:00
feat: add imdb_id parameter to update movie and show methods
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user