Skip to content

Commit 06dadd2

Browse files
authored
Merge pull request #225 from maxdorninger/remove-unnecessary-logs
Remove unnecessary logs
2 parents 9f6d43d + b819d3b commit 06dadd2

13 files changed

Lines changed: 22 additions & 232 deletions

File tree

media_manager/indexer/indexers/jackett.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def __init__(self, **kwargs):
2424
self.api_key = config.api_key
2525
self.url = config.url
2626
self.indexers = config.indexers
27-
log.debug("Registering Jacket as Indexer")
2827

29-
# NOTE: this could be done in parallel, but if there aren't more than a dozen indexers, it shouldn't matter
3028
def search(self, query: str, is_tv: bool) -> list[IndexerQueryResult]:
3129
log.debug("Searching for " + query)
3230

media_manager/indexer/indexers/prowlarr.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def __init__(self, **kwargs):
2626
self.api_key = config.api_key
2727
self.url = config.url
2828
self.reject_torrents_on_url_error = config.reject_torrents_on_url_error
29-
log.debug("Registering Prowlarr as Indexer")
3029

3130
def search(self, query: str, is_tv: bool) -> list[IndexerQueryResult]:
3231
log.debug("Searching for " + query)
@@ -44,7 +43,6 @@ def search(self, query: str, is_tv: bool) -> list[IndexerQueryResult]:
4443
session.mount("https://", adapter)
4544

4645
response = session.get(url, params=params)
47-
log.debug(f"Prowlarr response time for query '{query}': {response.elapsed}")
4846

4947
if response.status_code != 200:
5048
log.error(f"Prowlarr Error: {response.status_code}")
@@ -86,15 +84,10 @@ def process_result(
8684
# process torrent search result
8785
initial_url = None
8886
if "downloadUrl" in result:
89-
log.info(f"Using download URL: {result['downloadUrl']}")
9087
initial_url = result["downloadUrl"]
9188
elif "magnetUrl" in result:
92-
log.info(
93-
f"Using magnet URL as fallback for download URL: {result['magnetUrl']}"
94-
)
9589
initial_url = result["magnetUrl"]
9690
elif "guid" in result:
97-
log.warning(f"Using guid as fallback for download URL: {result['guid']}")
9891
initial_url = result["guid"]
9992
else:
10093
log.error(f"No valid download URL found for result: {result}")
@@ -107,7 +100,7 @@ def process_result(
107100
session=session,
108101
)
109102
except RuntimeError as e:
110-
log.debug(
103+
log.warning(
111104
f"Failed to follow redirects for {initial_url}, falling back to the initial url as download url, error: {e}"
112105
)
113106
if self.reject_torrents_on_url_error:

media_manager/indexer/repository.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ def get_result(self, result_id: IndexerQueryResultId) -> IndexerQueryResultSchem
2121
)
2222

2323
def save_result(self, result: IndexerQueryResultSchema) -> IndexerQueryResultSchema:
24-
log.debug("Saving indexer query result: %s", result)
25-
2624
result_data = result.model_dump()
2725
result_data["download_url"] = str(
2826
result.download_url

media_manager/indexer/service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,4 @@ def search(self, query: str, is_tv: bool) -> list[IndexerQueryResult]:
6868
for result in results:
6969
self.repository.save_result(result=result)
7070

71-
log.debug(f"Found torrents: {results}")
7271
return results

media_manager/metadataProvider/tmdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def search_show(
246246
)
247247
)
248248
except Exception as e:
249-
log.warning(f"Error processing search result {result}: {e}")
249+
log.warning(f"Error processing search result: {e}")
250250
return formatted_results
251251

252252
def get_movie_metadata(self, id: int = None) -> Movie:
@@ -315,7 +315,7 @@ def search_movie(
315315
)
316316
)
317317
except Exception as e:
318-
log.warning(f"Error processing search result {result}: {e}")
318+
log.warning(f"Error processing search result: {e}")
319319
return formatted_results
320320

321321
def download_movie_poster_image(self, movie: Movie) -> bool:

media_manager/metadataProvider/tvdb.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def download_show_poster_image(self, show: Show) -> bool:
5252
poster_url=show_metadata["image"],
5353
id=show.id,
5454
)
55-
log.info("Successfully downloaded poster image for show " + show.name)
55+
log.debug("Successfully downloaded poster image for show " + show.name)
5656
return True
5757
else:
5858
log.warning(f"image for show {show.name} could not be downloaded")
@@ -143,7 +143,7 @@ def search_show(
143143
)
144144
)
145145
except Exception as e:
146-
log.warning(f"Error processing search result {result}: {e}")
146+
log.warning(f"Error processing search result: {e}")
147147
return formatted_results
148148
else:
149149
results = self.__get_trending_tv()
@@ -169,7 +169,7 @@ def search_show(
169169
)
170170
)
171171
except Exception as e:
172-
log.warning(f"Error processing search result {result}: {e}")
172+
log.warning(f"Error processing search result: {e}")
173173
return formatted_results
174174

175175
def search_movie(
@@ -178,7 +178,7 @@ def search_movie(
178178
if query is None:
179179
results = self.__get_trending_movies()
180180
results = results[0:20]
181-
log.info(f"got {len(results)} results from TVDB search")
181+
log.debug(f"got {len(results)} results from TVDB search")
182182
formatted_results = []
183183
for result in results:
184184
result = self.__get_movie(result["id"])
@@ -201,12 +201,12 @@ def search_movie(
201201
)
202202
)
203203
except Exception as e:
204-
log.warning(f"Error processing search result {result}: {e}")
204+
log.warning(f"Error processing search result: {e}")
205205
return formatted_results
206206
else:
207207
results = self.__search_movie(query=query)
208208
results = results[0:20]
209-
log.info(f"got {len(results)} results from TVDB search")
209+
log.debug(f"got {len(results)} results from TVDB search")
210210
formatted_results = []
211211
for result in results:
212212
if result["type"] != "movie":
@@ -233,7 +233,7 @@ def search_movie(
233233
)
234234
)
235235
except Exception as e:
236-
log.warning(f"Error processing search result {result}: {e}")
236+
log.warning(f"Error processing search result: {e}")
237237
return formatted_results
238238

239239
def download_movie_poster_image(self, movie: Movie) -> bool:

media_manager/movies/repository.py

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

media_manager/movies/router.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def create_movie_request(
194194
)
195195
movie_request = MovieRequest.model_validate(movie_request)
196196
movie_request.requested_by = user
197-
log.info("SERVASasdasd")
198197
if user.is_superuser:
199198
movie_request.authorized = True
200199
movie_request.authorized_by = user

0 commit comments

Comments
 (0)