@@ -41,14 +41,11 @@ def get_movie_by_id(self, movie_id: MovieId) -> MovieSchema:
4141 :raises NotFoundError: If the movie with the given ID is not found.
4242 :raises SQLAlchemyError: If a database error occurs.
4343 """
44- log .debug (f"Attempting to retrieve movie with id: { movie_id } " )
4544 try :
4645 stmt = select (Movie ).where (Movie .id == movie_id )
4746 result = self .db .execute (stmt ).unique ().scalar_one_or_none ()
4847 if not result :
49- log .warning (f"Movie with id { movie_id } not found." )
5048 raise NotFoundError (f"Movie with id { movie_id } not found." )
51- log .info (f"Successfully retrieved movie with id: { movie_id } " )
5249 return MovieSchema .model_validate (result )
5350 except SQLAlchemyError as e :
5451 log .error (f"Database error while retrieving movie { movie_id } : { e } " )
@@ -66,9 +63,6 @@ def get_movie_by_external_id(
6663 :raises NotFoundError: If the movie with the given external ID and provider is not found.
6764 :raises SQLAlchemyError: If a database error occurs.
6865 """
69- log .debug (
70- f"Attempting to retrieve movie with external_id: { external_id } and provider: { metadata_provider } "
71- )
7266 try :
7367 stmt = (
7468 select (Movie )
@@ -77,15 +71,9 @@ def get_movie_by_external_id(
7771 )
7872 result = self .db .execute (stmt ).unique ().scalar_one_or_none ()
7973 if not result :
80- log .warning (
81- f"Movie with external_id { external_id } and provider { metadata_provider } not found."
82- )
8374 raise NotFoundError (
8475 f"Movie with external_id { external_id } and provider { metadata_provider } not found."
8576 )
86- log .info (
87- f"Successfully retrieved movie with external_id: { external_id } and provider: { metadata_provider } "
88- )
8977 return MovieSchema .model_validate (result )
9078 except SQLAlchemyError as e :
9179 log .error (
@@ -100,11 +88,9 @@ def get_movies(self) -> list[MovieSchema]:
10088 :return: A list of Movie objects.
10189 :raises SQLAlchemyError: If a database error occurs.
10290 """
103- log .debug ("Attempting to retrieve all movies." )
10491 try :
10592 stmt = select (Movie )
10693 results = self .db .execute (stmt ).scalars ().unique ().all ()
107- log .info (f"Successfully retrieved { len (results )} movies." )
10894 return [MovieSchema .model_validate (movie ) for movie in results ]
10995 except SQLAlchemyError as e :
11096 log .error (f"Database error while retrieving all movies: { e } " )
@@ -221,15 +207,12 @@ def set_movie_library(self, movie_id: MovieId, library: str) -> None:
221207 :raises NotFoundError: If the movie with the given ID is not found.
222208 :raises SQLAlchemyError: If a database error occurs.
223209 """
224- log .debug (f"Setting library for movie_id { movie_id } to { library } " )
225210 try :
226211 movie = self .db .get (Movie , movie_id )
227212 if not movie :
228- log .warning (f"movie with id { movie_id } not found." )
229213 raise NotFoundError (f"movie with id { movie_id } not found." )
230214 movie .library = library
231215 self .db .commit ()
232- log .info (f"Successfully set library for movie_id { movie_id } to { library } " )
233216 except SQLAlchemyError as e :
234217 self .db .rollback ()
235218 log .error (f"Database error setting library for movie { movie_id } : { e } " )
@@ -243,16 +226,14 @@ def delete_movie_request(self, movie_request_id: MovieRequestId) -> None:
243226 :raises NotFoundError: If the movie request is not found.
244227 :raises SQLAlchemyError: If a database error occurs.
245228 """
246- log .debug (f"Attempting to delete movie request with id: { movie_request_id } " )
247229 try :
248230 stmt = delete (MovieRequest ).where (MovieRequest .id == movie_request_id )
249231 result = self .db .execute (stmt )
250232 if result .rowcount == 0 :
251- log .warning (
252- f"Movie request with id { movie_request_id } not found during delete execution (rowcount 0)."
253- )
233+ self .db .rollback ()
234+ raise NotFoundError (f"movie request with id { movie_request_id } not found." )
254235 self .db .commit ()
255- log . info ( f" Successfully deleted movie request with id: { movie_request_id } " )
236+ # Successfully deleted movie request with id: {movie_request_id}
256237 except SQLAlchemyError as e :
257238 self .db .rollback ()
258239 log .error (
@@ -267,15 +248,13 @@ def get_movie_requests(self) -> list[RichMovieRequestSchema]:
267248 :return: A list of RichMovieRequest objects.
268249 :raises SQLAlchemyError: If a database error occurs.
269250 """
270- log .debug ("Attempting to retrieve all movie requests." )
271251 try :
272252 stmt = select (MovieRequest ).options (
273253 joinedload (MovieRequest .requested_by ),
274254 joinedload (MovieRequest .authorized_by ),
275255 joinedload (MovieRequest .movie ),
276256 )
277257 results = self .db .execute (stmt ).scalars ().unique ().all ()
278- log .info (f"Successfully retrieved { len (results )} movie requests." )
279258 return [RichMovieRequestSchema .model_validate (x ) for x in results ]
280259 except SQLAlchemyError as e :
281260 log .error (f"Database error while retrieving movie requests: { e } " )
@@ -290,15 +269,11 @@ def add_movie_file(self, movie_file: MovieFileSchema) -> MovieFileSchema:
290269 :raises IntegrityError: If the record violates constraints.
291270 :raises SQLAlchemyError: If a database error occurs.
292271 """
293- log .debug (f"Adding movie file: { movie_file .model_dump_json ()} " )
294272 db_model = MovieFile (** movie_file .model_dump ())
295273 try :
296274 self .db .add (db_model )
297275 self .db .commit ()
298276 self .db .refresh (db_model )
299- log .info (
300- f"Successfully added movie file. Torrent ID: { db_model .torrent_id } , Path: { db_model .file_path_suffix } "
301- )
302277 return MovieFileSchema .model_validate (db_model )
303278 except IntegrityError as e :
304279 self .db .rollback ()
@@ -317,15 +292,11 @@ def remove_movie_files_by_torrent_id(self, torrent_id: TorrentId) -> int:
317292 :return: The number of movie files removed.
318293 :raises SQLAlchemyError: If a database error occurs.
319294 """
320- log .debug (f"Attempting to remove movie files for torrent_id: { torrent_id } " )
321295 try :
322296 stmt = delete (MovieFile ).where (MovieFile .torrent_id == torrent_id )
323297 result = self .db .execute (stmt )
324298 self .db .commit ()
325299 deleted_count = result .rowcount
326- log .info (
327- f"Successfully removed { deleted_count } movie files for torrent_id: { torrent_id } "
328- )
329300 return deleted_count
330301 except SQLAlchemyError as e :
331302 self .db .rollback ()
@@ -342,13 +313,9 @@ def get_movie_files_by_movie_id(self, movie_id: MovieId) -> list[MovieFileSchema
342313 :return: A list of MovieFile objects.
343314 :raises SQLAlchemyError: If a database error occurs.
344315 """
345- log .debug (f"Attempting to retrieve movie files for movie_id: { movie_id } " )
346316 try :
347317 stmt = select (MovieFile ).where (MovieFile .movie_id == movie_id )
348318 results = self .db .execute (stmt ).scalars ().all ()
349- log .info (
350- f"Successfully retrieved { len (results )} movie files for movie_id: { movie_id } "
351- )
352319 return [MovieFileSchema .model_validate (sf ) for sf in results ]
353320 except SQLAlchemyError as e :
354321 log .error (
@@ -364,7 +331,6 @@ def get_torrents_by_movie_id(self, movie_id: MovieId) -> list[MovieTorrentSchema
364331 :return: A list of Torrent objects.
365332 :raises SQLAlchemyError: If a database error occurs.
366333 """
367- log .debug (f"Attempting to retrieve torrents for movie_id: { movie_id } " )
368334 try :
369335 stmt = (
370336 select (Torrent , MovieFile .file_path_suffix )
@@ -373,9 +339,6 @@ def get_torrents_by_movie_id(self, movie_id: MovieId) -> list[MovieTorrentSchema
373339 .where (MovieFile .movie_id == movie_id )
374340 )
375341 results = self .db .execute (stmt ).all ()
376- log .info (
377- f"Successfully retrieved { len (results )} torrents for movie_id: { movie_id } "
378- )
379342 formatted_results = []
380343 for torrent , file_path_suffix in results :
381344 movie_torrent = MovieTorrentSchema (
@@ -402,7 +365,6 @@ def get_all_movies_with_torrents(self) -> list[MovieSchema]:
402365 :return: A list of Movie objects.
403366 :raises SQLAlchemyError: If a database error occurs.
404367 """
405- log .debug ("Attempting to retrieve all movies with torrents." )
406368 try :
407369 stmt = (
408370 select (Movie )
@@ -412,7 +374,6 @@ def get_all_movies_with_torrents(self) -> list[MovieSchema]:
412374 .order_by (Movie .name )
413375 )
414376 results = self .db .execute (stmt ).scalars ().unique ().all ()
415- log .info (f"Successfully retrieved { len (results )} movies with torrents." )
416377 return [MovieSchema .model_validate (movie ) for movie in results ]
417378 except SQLAlchemyError as e :
418379 log .error (f"Database error retrieving all movies with torrents: { e } " )
@@ -427,17 +388,12 @@ def get_movie_request(self, movie_request_id: MovieRequestId) -> MovieRequestSch
427388 :raises NotFoundError: If the movie request is not found.
428389 :raises SQLAlchemyError: If a database error occurs.
429390 """
430- log .debug (f"Attempting to retrieve movie request with id: { movie_request_id } " )
431391 try :
432392 request = self .db .get (MovieRequest , movie_request_id )
433393 if not request :
434- log .warning (f"Movie request with id { movie_request_id } not found." )
435394 raise NotFoundError (
436395 f"Movie request with id { movie_request_id } not found."
437396 )
438- log .info (
439- f"Successfully retrieved movie request with id: { movie_request_id } "
440- )
441397 return MovieRequestSchema .model_validate (request )
442398 except SQLAlchemyError as e :
443399 log .error (
@@ -454,7 +410,6 @@ def get_movie_by_torrent_id(self, torrent_id: TorrentId) -> MovieSchema:
454410 :raises NotFoundError: If the movie for the given torrent ID is not found.
455411 :raises SQLAlchemyError: If a database error occurs.
456412 """
457- log .debug (f"Attempting to retrieve movie by torrent_id: { torrent_id } " )
458413 try :
459414 stmt = (
460415 select (Movie )
@@ -463,9 +418,7 @@ def get_movie_by_torrent_id(self, torrent_id: TorrentId) -> MovieSchema:
463418 )
464419 result = self .db .execute (stmt ).unique ().scalar_one_or_none ()
465420 if not result :
466- log .warning (f"Movie for torrent_id { torrent_id } not found." )
467421 raise NotFoundError (f"Movie for torrent_id { torrent_id } not found." )
468- log .info (f"Successfully retrieved movie for torrent_id: { torrent_id } " )
469422 return MovieSchema .model_validate (result )
470423 except SQLAlchemyError as e :
471424 log .error (
@@ -489,10 +442,8 @@ def update_movie_attributes(
489442 :param year: The new year for the movie.
490443 :return: The updated MovieSchema object.
491444 """
492- log .debug (f"Attempting to update attributes for movie ID: { movie_id } " )
493445 db_movie = self .db .get (Movie , movie_id )
494446 if not db_movie :
495- log .warning (f"Movie with id { movie_id } not found for attribute update." )
496447 raise NotFoundError (f"Movie with id { movie_id } not found." )
497448
498449 updated = False
@@ -509,7 +460,4 @@ def update_movie_attributes(
509460 if updated :
510461 self .db .commit ()
511462 self .db .refresh (db_movie )
512- log .info (f"Successfully updated attributes for movie ID: { movie_id } " )
513- else :
514- log .info (f"No attribute changes needed for movie ID: { movie_id } " )
515463 return MovieSchema .model_validate (db_movie )
0 commit comments