mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:13:24 +02:00
Merge pull request #225 from maxdorninger/remove-unnecessary-logs
Remove unnecessary logs
This commit is contained in:
@@ -24,9 +24,7 @@ class Jackett(GenericIndexer):
|
||||
self.api_key = config.api_key
|
||||
self.url = config.url
|
||||
self.indexers = config.indexers
|
||||
log.debug("Registering Jacket as Indexer")
|
||||
|
||||
# NOTE: this could be done in parallel, but if there aren't more than a dozen indexers, it shouldn't matter
|
||||
def search(self, query: str, is_tv: bool) -> list[IndexerQueryResult]:
|
||||
log.debug("Searching for " + query)
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ class Prowlarr(GenericIndexer):
|
||||
self.api_key = config.api_key
|
||||
self.url = config.url
|
||||
self.reject_torrents_on_url_error = config.reject_torrents_on_url_error
|
||||
log.debug("Registering Prowlarr as Indexer")
|
||||
|
||||
def search(self, query: str, is_tv: bool) -> list[IndexerQueryResult]:
|
||||
log.debug("Searching for " + query)
|
||||
@@ -44,7 +43,6 @@ class Prowlarr(GenericIndexer):
|
||||
session.mount("https://", adapter)
|
||||
|
||||
response = session.get(url, params=params)
|
||||
log.debug(f"Prowlarr response time for query '{query}': {response.elapsed}")
|
||||
|
||||
if response.status_code != 200:
|
||||
log.error(f"Prowlarr Error: {response.status_code}")
|
||||
@@ -86,15 +84,10 @@ class Prowlarr(GenericIndexer):
|
||||
# process torrent search result
|
||||
initial_url = None
|
||||
if "downloadUrl" in result:
|
||||
log.info(f"Using download URL: {result['downloadUrl']}")
|
||||
initial_url = result["downloadUrl"]
|
||||
elif "magnetUrl" in result:
|
||||
log.info(
|
||||
f"Using magnet URL as fallback for download URL: {result['magnetUrl']}"
|
||||
)
|
||||
initial_url = result["magnetUrl"]
|
||||
elif "guid" in result:
|
||||
log.warning(f"Using guid as fallback for download URL: {result['guid']}")
|
||||
initial_url = result["guid"]
|
||||
else:
|
||||
log.error(f"No valid download URL found for result: {result}")
|
||||
@@ -107,7 +100,7 @@ class Prowlarr(GenericIndexer):
|
||||
session=session,
|
||||
)
|
||||
except RuntimeError as e:
|
||||
log.debug(
|
||||
log.warning(
|
||||
f"Failed to follow redirects for {initial_url}, falling back to the initial url as download url, error: {e}"
|
||||
)
|
||||
if self.reject_torrents_on_url_error:
|
||||
|
||||
@@ -21,8 +21,6 @@ class IndexerRepository:
|
||||
)
|
||||
|
||||
def save_result(self, result: IndexerQueryResultSchema) -> IndexerQueryResultSchema:
|
||||
log.debug("Saving indexer query result: %s", result)
|
||||
|
||||
result_data = result.model_dump()
|
||||
result_data["download_url"] = str(
|
||||
result.download_url
|
||||
|
||||
@@ -68,5 +68,4 @@ class IndexerService:
|
||||
for result in results:
|
||||
self.repository.save_result(result=result)
|
||||
|
||||
log.debug(f"Found torrents: {results}")
|
||||
return results
|
||||
|
||||
@@ -246,7 +246,7 @@ class TmdbMetadataProvider(AbstractMetadataProvider):
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
log.warning(f"Error processing search result {result}: {e}")
|
||||
log.warning(f"Error processing search result: {e}")
|
||||
return formatted_results
|
||||
|
||||
def get_movie_metadata(self, id: int = None) -> Movie:
|
||||
@@ -315,7 +315,7 @@ class TmdbMetadataProvider(AbstractMetadataProvider):
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
log.warning(f"Error processing search result {result}: {e}")
|
||||
log.warning(f"Error processing search result: {e}")
|
||||
return formatted_results
|
||||
|
||||
def download_movie_poster_image(self, movie: Movie) -> bool:
|
||||
|
||||
@@ -52,7 +52,7 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
|
||||
poster_url=show_metadata["image"],
|
||||
id=show.id,
|
||||
)
|
||||
log.info("Successfully downloaded poster image for show " + show.name)
|
||||
log.debug("Successfully downloaded poster image for show " + show.name)
|
||||
return True
|
||||
else:
|
||||
log.warning(f"image for show {show.name} could not be downloaded")
|
||||
@@ -143,7 +143,7 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
log.warning(f"Error processing search result {result}: {e}")
|
||||
log.warning(f"Error processing search result: {e}")
|
||||
return formatted_results
|
||||
else:
|
||||
results = self.__get_trending_tv()
|
||||
@@ -169,7 +169,7 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
log.warning(f"Error processing search result {result}: {e}")
|
||||
log.warning(f"Error processing search result: {e}")
|
||||
return formatted_results
|
||||
|
||||
def search_movie(
|
||||
@@ -178,7 +178,7 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
|
||||
if query is None:
|
||||
results = self.__get_trending_movies()
|
||||
results = results[0:20]
|
||||
log.info(f"got {len(results)} results from TVDB search")
|
||||
log.debug(f"got {len(results)} results from TVDB search")
|
||||
formatted_results = []
|
||||
for result in results:
|
||||
result = self.__get_movie(result["id"])
|
||||
@@ -201,12 +201,12 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
log.warning(f"Error processing search result {result}: {e}")
|
||||
log.warning(f"Error processing search result: {e}")
|
||||
return formatted_results
|
||||
else:
|
||||
results = self.__search_movie(query=query)
|
||||
results = results[0:20]
|
||||
log.info(f"got {len(results)} results from TVDB search")
|
||||
log.debug(f"got {len(results)} results from TVDB search")
|
||||
formatted_results = []
|
||||
for result in results:
|
||||
if result["type"] != "movie":
|
||||
@@ -233,7 +233,7 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
log.warning(f"Error processing search result {result}: {e}")
|
||||
log.warning(f"Error processing search result: {e}")
|
||||
return formatted_results
|
||||
|
||||
def download_movie_poster_image(self, movie: Movie) -> bool:
|
||||
|
||||
@@ -41,14 +41,11 @@ class MovieRepository:
|
||||
:raises NotFoundError: If the movie with the given ID is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve movie with id: {movie_id}")
|
||||
try:
|
||||
stmt = select(Movie).where(Movie.id == movie_id)
|
||||
result = self.db.execute(stmt).unique().scalar_one_or_none()
|
||||
if not result:
|
||||
log.warning(f"Movie with id {movie_id} not found.")
|
||||
raise NotFoundError(f"Movie with id {movie_id} not found.")
|
||||
log.info(f"Successfully retrieved movie with id: {movie_id}")
|
||||
return MovieSchema.model_validate(result)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error while retrieving movie {movie_id}: {e}")
|
||||
@@ -66,9 +63,6 @@ class MovieRepository:
|
||||
:raises NotFoundError: If the movie with the given external ID and provider is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(
|
||||
f"Attempting to retrieve movie with external_id: {external_id} and provider: {metadata_provider}"
|
||||
)
|
||||
try:
|
||||
stmt = (
|
||||
select(Movie)
|
||||
@@ -77,15 +71,9 @@ class MovieRepository:
|
||||
)
|
||||
result = self.db.execute(stmt).unique().scalar_one_or_none()
|
||||
if not result:
|
||||
log.warning(
|
||||
f"Movie with external_id {external_id} and provider {metadata_provider} not found."
|
||||
)
|
||||
raise NotFoundError(
|
||||
f"Movie with external_id {external_id} and provider {metadata_provider} not found."
|
||||
)
|
||||
log.info(
|
||||
f"Successfully retrieved movie with external_id: {external_id} and provider: {metadata_provider}"
|
||||
)
|
||||
return MovieSchema.model_validate(result)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -100,11 +88,9 @@ class MovieRepository:
|
||||
:return: A list of Movie objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug("Attempting to retrieve all movies.")
|
||||
try:
|
||||
stmt = select(Movie)
|
||||
results = self.db.execute(stmt).scalars().unique().all()
|
||||
log.info(f"Successfully retrieved {len(results)} movies.")
|
||||
return [MovieSchema.model_validate(movie) for movie in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error while retrieving all movies: {e}")
|
||||
@@ -221,15 +207,12 @@ class MovieRepository:
|
||||
:raises NotFoundError: If the movie with the given ID is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Setting library for movie_id {movie_id} to {library}")
|
||||
try:
|
||||
movie = self.db.get(Movie, movie_id)
|
||||
if not movie:
|
||||
log.warning(f"movie with id {movie_id} not found.")
|
||||
raise NotFoundError(f"movie with id {movie_id} not found.")
|
||||
movie.library = library
|
||||
self.db.commit()
|
||||
log.info(f"Successfully set library for movie_id {movie_id} to {library}")
|
||||
except SQLAlchemyError as e:
|
||||
self.db.rollback()
|
||||
log.error(f"Database error setting library for movie {movie_id}: {e}")
|
||||
@@ -243,16 +226,14 @@ class MovieRepository:
|
||||
:raises NotFoundError: If the movie request is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to delete movie request with id: {movie_request_id}")
|
||||
try:
|
||||
stmt = delete(MovieRequest).where(MovieRequest.id == movie_request_id)
|
||||
result = self.db.execute(stmt)
|
||||
if result.rowcount == 0:
|
||||
log.warning(
|
||||
f"Movie request with id {movie_request_id} not found during delete execution (rowcount 0)."
|
||||
)
|
||||
self.db.rollback()
|
||||
raise NotFoundError(f"movie request with id {movie_request_id} not found.")
|
||||
self.db.commit()
|
||||
log.info(f"Successfully deleted movie request with id: {movie_request_id}")
|
||||
# Successfully deleted movie request with id: {movie_request_id}
|
||||
except SQLAlchemyError as e:
|
||||
self.db.rollback()
|
||||
log.error(
|
||||
@@ -267,7 +248,6 @@ class MovieRepository:
|
||||
:return: A list of RichMovieRequest objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug("Attempting to retrieve all movie requests.")
|
||||
try:
|
||||
stmt = select(MovieRequest).options(
|
||||
joinedload(MovieRequest.requested_by),
|
||||
@@ -275,7 +255,6 @@ class MovieRepository:
|
||||
joinedload(MovieRequest.movie),
|
||||
)
|
||||
results = self.db.execute(stmt).scalars().unique().all()
|
||||
log.info(f"Successfully retrieved {len(results)} movie requests.")
|
||||
return [RichMovieRequestSchema.model_validate(x) for x in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error while retrieving movie requests: {e}")
|
||||
@@ -290,15 +269,11 @@ class MovieRepository:
|
||||
:raises IntegrityError: If the record violates constraints.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Adding movie file: {movie_file.model_dump_json()}")
|
||||
db_model = MovieFile(**movie_file.model_dump())
|
||||
try:
|
||||
self.db.add(db_model)
|
||||
self.db.commit()
|
||||
self.db.refresh(db_model)
|
||||
log.info(
|
||||
f"Successfully added movie file. Torrent ID: {db_model.torrent_id}, Path: {db_model.file_path_suffix}"
|
||||
)
|
||||
return MovieFileSchema.model_validate(db_model)
|
||||
except IntegrityError as e:
|
||||
self.db.rollback()
|
||||
@@ -317,15 +292,11 @@ class MovieRepository:
|
||||
:return: The number of movie files removed.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to remove movie files for torrent_id: {torrent_id}")
|
||||
try:
|
||||
stmt = delete(MovieFile).where(MovieFile.torrent_id == torrent_id)
|
||||
result = self.db.execute(stmt)
|
||||
self.db.commit()
|
||||
deleted_count = result.rowcount
|
||||
log.info(
|
||||
f"Successfully removed {deleted_count} movie files for torrent_id: {torrent_id}"
|
||||
)
|
||||
return deleted_count
|
||||
except SQLAlchemyError as e:
|
||||
self.db.rollback()
|
||||
@@ -342,13 +313,9 @@ class MovieRepository:
|
||||
:return: A list of MovieFile objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve movie files for movie_id: {movie_id}")
|
||||
try:
|
||||
stmt = select(MovieFile).where(MovieFile.movie_id == movie_id)
|
||||
results = self.db.execute(stmt).scalars().all()
|
||||
log.info(
|
||||
f"Successfully retrieved {len(results)} movie files for movie_id: {movie_id}"
|
||||
)
|
||||
return [MovieFileSchema.model_validate(sf) for sf in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -364,7 +331,6 @@ class MovieRepository:
|
||||
:return: A list of Torrent objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve torrents for movie_id: {movie_id}")
|
||||
try:
|
||||
stmt = (
|
||||
select(Torrent, MovieFile.file_path_suffix)
|
||||
@@ -373,9 +339,6 @@ class MovieRepository:
|
||||
.where(MovieFile.movie_id == movie_id)
|
||||
)
|
||||
results = self.db.execute(stmt).all()
|
||||
log.info(
|
||||
f"Successfully retrieved {len(results)} torrents for movie_id: {movie_id}"
|
||||
)
|
||||
formatted_results = []
|
||||
for torrent, file_path_suffix in results:
|
||||
movie_torrent = MovieTorrentSchema(
|
||||
@@ -402,7 +365,6 @@ class MovieRepository:
|
||||
:return: A list of Movie objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug("Attempting to retrieve all movies with torrents.")
|
||||
try:
|
||||
stmt = (
|
||||
select(Movie)
|
||||
@@ -412,7 +374,6 @@ class MovieRepository:
|
||||
.order_by(Movie.name)
|
||||
)
|
||||
results = self.db.execute(stmt).scalars().unique().all()
|
||||
log.info(f"Successfully retrieved {len(results)} movies with torrents.")
|
||||
return [MovieSchema.model_validate(movie) for movie in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error retrieving all movies with torrents: {e}")
|
||||
@@ -427,17 +388,12 @@ class MovieRepository:
|
||||
:raises NotFoundError: If the movie request is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve movie request with id: {movie_request_id}")
|
||||
try:
|
||||
request = self.db.get(MovieRequest, movie_request_id)
|
||||
if not request:
|
||||
log.warning(f"Movie request with id {movie_request_id} not found.")
|
||||
raise NotFoundError(
|
||||
f"Movie request with id {movie_request_id} not found."
|
||||
)
|
||||
log.info(
|
||||
f"Successfully retrieved movie request with id: {movie_request_id}"
|
||||
)
|
||||
return MovieRequestSchema.model_validate(request)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -454,7 +410,6 @@ class MovieRepository:
|
||||
:raises NotFoundError: If the movie for the given torrent ID is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve movie by torrent_id: {torrent_id}")
|
||||
try:
|
||||
stmt = (
|
||||
select(Movie)
|
||||
@@ -463,9 +418,7 @@ class MovieRepository:
|
||||
)
|
||||
result = self.db.execute(stmt).unique().scalar_one_or_none()
|
||||
if not result:
|
||||
log.warning(f"Movie for torrent_id {torrent_id} not found.")
|
||||
raise NotFoundError(f"Movie for torrent_id {torrent_id} not found.")
|
||||
log.info(f"Successfully retrieved movie for torrent_id: {torrent_id}")
|
||||
return MovieSchema.model_validate(result)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -489,10 +442,8 @@ class MovieRepository:
|
||||
:param year: The new year for the movie.
|
||||
:return: The updated MovieSchema object.
|
||||
"""
|
||||
log.debug(f"Attempting to update attributes for movie ID: {movie_id}")
|
||||
db_movie = self.db.get(Movie, movie_id)
|
||||
if not db_movie:
|
||||
log.warning(f"Movie with id {movie_id} not found for attribute update.")
|
||||
raise NotFoundError(f"Movie with id {movie_id} not found.")
|
||||
|
||||
updated = False
|
||||
@@ -509,7 +460,4 @@ class MovieRepository:
|
||||
if updated:
|
||||
self.db.commit()
|
||||
self.db.refresh(db_movie)
|
||||
log.info(f"Successfully updated attributes for movie ID: {movie_id}")
|
||||
else:
|
||||
log.info(f"No attribute changes needed for movie ID: {movie_id}")
|
||||
return MovieSchema.model_validate(db_movie)
|
||||
|
||||
@@ -194,7 +194,6 @@ def create_movie_request(
|
||||
)
|
||||
movie_request = MovieRequest.model_validate(movie_request)
|
||||
movie_request.requested_by = user
|
||||
log.info("SERVASasdasd")
|
||||
if user.is_superuser:
|
||||
movie_request.authorized = True
|
||||
movie_request.authorized_by = user
|
||||
|
||||
@@ -189,9 +189,7 @@ class MovieService:
|
||||
)
|
||||
|
||||
if search_query_override:
|
||||
log.debug(
|
||||
f"Found with search query override {torrents.__len__()} torrents: {torrents}"
|
||||
)
|
||||
log.debug(f"Found with search query override {torrents.__len__()} torrents")
|
||||
return torrents
|
||||
|
||||
result: list[IndexerQueryResult] = []
|
||||
@@ -623,7 +621,9 @@ class MovieService:
|
||||
try:
|
||||
source_directory.rename(new_source_path)
|
||||
except Exception as e:
|
||||
log.error(f"Failed to rename directory '{source_directory}' to '{new_source_path}': {e}")
|
||||
log.error(
|
||||
f"Failed to rename directory '{source_directory}' to '{new_source_path}': {e}"
|
||||
)
|
||||
return False
|
||||
|
||||
return success
|
||||
@@ -680,12 +680,10 @@ def auto_download_all_approved_movie_requests() -> None:
|
||||
log.info("Auto downloading all approved movie requests")
|
||||
movie_requests = movie_repository.get_movie_requests()
|
||||
log.info(f"Found {len(movie_requests)} movie requests to process")
|
||||
log.debug(f"Movie requests: {[x.model_dump() for x in movie_requests]}")
|
||||
count = 0
|
||||
|
||||
for movie_request in movie_requests:
|
||||
if movie_request.authorized:
|
||||
log.info(f"Processing movie request {movie_request.id} for download")
|
||||
movie = movie_repository.get_movie_by_id(movie_id=movie_request.movie_id)
|
||||
if movie_service.download_approved_movie_request(
|
||||
movie_request=movie_request, movie=movie
|
||||
|
||||
@@ -36,7 +36,6 @@ class NotificationRepository:
|
||||
.order_by(Notification.timestamp.desc())
|
||||
)
|
||||
results = self.db.execute(stmt).scalars().all()
|
||||
log.info(f"Successfully retrieved {len(results)} unread notifications.")
|
||||
return [
|
||||
NotificationSchema.model_validate(notification)
|
||||
for notification in results
|
||||
@@ -49,7 +48,6 @@ class NotificationRepository:
|
||||
try:
|
||||
stmt = select(Notification).order_by(Notification.timestamp.desc())
|
||||
results = self.db.execute(stmt).scalars().all()
|
||||
log.info(f"Successfully retrieved {len(results)} notifications.")
|
||||
return [
|
||||
NotificationSchema.model_validate(notification)
|
||||
for notification in results
|
||||
@@ -90,8 +88,6 @@ class NotificationRepository:
|
||||
stmt = delete(Notification).where(Notification.id == id)
|
||||
result = self.db.execute(stmt)
|
||||
if result.rowcount == 0:
|
||||
log.warning(f"Notification with id {id} not found for deletion.")
|
||||
raise NotFoundError(f"Notification with id {id} not found.")
|
||||
self.db.commit()
|
||||
log.info(f"Successfully deleted notification with id: {id}")
|
||||
return
|
||||
|
||||
@@ -43,7 +43,6 @@ class TvRepository:
|
||||
:raises NotFoundError: If the show with the given ID is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve show with id: {show_id}")
|
||||
try:
|
||||
stmt = (
|
||||
select(Show)
|
||||
@@ -52,9 +51,7 @@ class TvRepository:
|
||||
)
|
||||
result = self.db.execute(stmt).unique().scalar_one_or_none()
|
||||
if not result:
|
||||
log.warning(f"Show with id {show_id} not found.")
|
||||
raise NotFoundError(f"Show with id {show_id} not found.")
|
||||
log.info(f"Successfully retrieved show with id: {show_id}")
|
||||
return ShowSchema.model_validate(result)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error while retrieving show {show_id}: {e}")
|
||||
@@ -72,9 +69,6 @@ class TvRepository:
|
||||
:raises NotFoundError: If the show with the given external ID and provider is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(
|
||||
f"Attempting to retrieve show with external_id: {external_id} and provider: {metadata_provider}"
|
||||
)
|
||||
try:
|
||||
stmt = (
|
||||
select(Show)
|
||||
@@ -84,15 +78,9 @@ class TvRepository:
|
||||
)
|
||||
result = self.db.execute(stmt).unique().scalar_one_or_none()
|
||||
if not result:
|
||||
log.warning(
|
||||
f"Show with external_id {external_id} and provider {metadata_provider} not found."
|
||||
)
|
||||
raise NotFoundError(
|
||||
f"Show with external_id {external_id} and provider {metadata_provider} not found."
|
||||
)
|
||||
log.info(
|
||||
f"Successfully retrieved show with external_id: {external_id} and provider: {metadata_provider}"
|
||||
)
|
||||
return ShowSchema.model_validate(result)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -107,26 +95,22 @@ class TvRepository:
|
||||
:return: A list of Show objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug("Attempting to retrieve all shows.")
|
||||
try:
|
||||
stmt = select(Show).options(
|
||||
joinedload(Show.seasons).joinedload(Season.episodes)
|
||||
) # Eager load seasons and episodes
|
||||
results = self.db.execute(stmt).scalars().unique().all()
|
||||
log.info(f"Successfully retrieved {len(results)} shows.")
|
||||
return [ShowSchema.model_validate(show) for show in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error while retrieving all shows: {e}")
|
||||
raise
|
||||
|
||||
def get_total_downloaded_episodes_count(self) -> int:
|
||||
log.debug("Calculating total downloaded episodes count.")
|
||||
try:
|
||||
stmt = (
|
||||
select(func.count()).select_from(Episode).join(Season).join(SeasonFile)
|
||||
)
|
||||
total_count = self.db.execute(stmt).scalar_one_or_none()
|
||||
log.info(f"Total downloaded episodes count: {total_count}")
|
||||
return total_count
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -143,18 +127,15 @@ class TvRepository:
|
||||
:raises ValueError: If a show with the same primary key already exists (on insert).
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to save show: {show.name} (ID: {show.id})")
|
||||
db_show = self.db.get(Show, show.id) if show.id else None
|
||||
|
||||
if db_show: # Update existing show
|
||||
log.debug(f"Updating existing show with ID: {show.id}")
|
||||
db_show.external_id = show.external_id
|
||||
db_show.metadata_provider = show.metadata_provider
|
||||
db_show.name = show.name
|
||||
db_show.overview = show.overview
|
||||
db_show.year = show.year
|
||||
else: # Insert new show
|
||||
log.debug(f"Creating new show: {show.name}")
|
||||
db_show = Show(
|
||||
id=show.id,
|
||||
external_id=show.external_id,
|
||||
@@ -190,11 +171,9 @@ class TvRepository:
|
||||
try:
|
||||
self.db.commit()
|
||||
self.db.refresh(db_show)
|
||||
log.info(f"Successfully saved show: {db_show.name} (ID: {db_show.id})")
|
||||
return ShowSchema.model_validate(db_show)
|
||||
except IntegrityError as e:
|
||||
self.db.rollback()
|
||||
log.error(f"Integrity error while saving show {show.name}: {e}")
|
||||
raise MediaAlreadyExists(
|
||||
f"Show with this primary key or unique constraint violation: {e.orig}"
|
||||
) from e
|
||||
@@ -211,15 +190,12 @@ class TvRepository:
|
||||
:raises NotFoundError: If the show with the given ID is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to delete show with id: {show_id}")
|
||||
try:
|
||||
show = self.db.get(Show, show_id)
|
||||
if not show:
|
||||
log.warning(f"Show with id {show_id} not found for deletion.")
|
||||
raise NotFoundError(f"Show with id {show_id} not found.")
|
||||
self.db.delete(show)
|
||||
self.db.commit()
|
||||
log.info(f"Successfully deleted show with id: {show_id}")
|
||||
except SQLAlchemyError as e:
|
||||
self.db.rollback()
|
||||
log.error(f"Database error while deleting show {show_id}: {e}")
|
||||
@@ -234,13 +210,10 @@ class TvRepository:
|
||||
:raises NotFoundError: If the season with the given ID is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve season with id: {season_id}")
|
||||
try:
|
||||
season = self.db.get(Season, season_id)
|
||||
if not season:
|
||||
log.warning(f"Season with id {season_id} not found.")
|
||||
raise NotFoundError(f"Season with id {season_id} not found.")
|
||||
log.info(f"Successfully retrieved season with id: {season_id}")
|
||||
return SeasonSchema.model_validate(season)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error while retrieving season {season_id}: {e}")
|
||||
@@ -257,7 +230,6 @@ class TvRepository:
|
||||
:raises IntegrityError: If a similar request already exists or violates constraints.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Adding season request: {season_request.model_dump_json()}")
|
||||
db_model = SeasonRequest(
|
||||
id=season_request.id,
|
||||
season_id=season_request.season_id,
|
||||
@@ -275,7 +247,6 @@ class TvRepository:
|
||||
self.db.add(db_model)
|
||||
self.db.commit()
|
||||
self.db.refresh(db_model)
|
||||
log.info(f"Successfully added season request with id: {db_model.id}")
|
||||
return SeasonRequestSchema.model_validate(db_model)
|
||||
except IntegrityError as e:
|
||||
self.db.rollback()
|
||||
@@ -294,18 +265,13 @@ class TvRepository:
|
||||
:raises NotFoundError: If the season request is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to delete season request with id: {season_request_id}")
|
||||
try:
|
||||
stmt = delete(SeasonRequest).where(SeasonRequest.id == season_request_id)
|
||||
result = self.db.execute(stmt)
|
||||
if result.rowcount == 0:
|
||||
log.warning(
|
||||
f"Season request with id {season_request_id} not found during delete execution (rowcount 0)."
|
||||
)
|
||||
self.db.rollback()
|
||||
raise NotFoundError(f"SeasonRequest with id {season_request_id} not found.")
|
||||
self.db.commit()
|
||||
log.info(
|
||||
f"Successfully deleted season request with id: {season_request_id}"
|
||||
)
|
||||
except SQLAlchemyError as e:
|
||||
self.db.rollback()
|
||||
log.error(
|
||||
@@ -323,9 +289,6 @@ class TvRepository:
|
||||
:raises NotFoundError: If the season is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(
|
||||
f"Attempting to retrieve season number {season_number} for show_id: {show_id}"
|
||||
)
|
||||
try:
|
||||
stmt = (
|
||||
select(Season)
|
||||
@@ -335,15 +298,9 @@ class TvRepository:
|
||||
)
|
||||
result = self.db.execute(stmt).unique().scalar_one_or_none()
|
||||
if not result:
|
||||
log.warning(
|
||||
f"Season number {season_number} for show_id {show_id} not found."
|
||||
)
|
||||
raise NotFoundError(
|
||||
f"Season number {season_number} for show_id {show_id} not found."
|
||||
)
|
||||
log.info(
|
||||
f"Successfully retrieved season number {season_number} for show_id: {show_id}"
|
||||
)
|
||||
return SeasonSchema.model_validate(result)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -358,7 +315,6 @@ class TvRepository:
|
||||
:return: A list of RichSeasonRequest objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug("Attempting to retrieve all season requests.")
|
||||
try:
|
||||
stmt = select(SeasonRequest).options(
|
||||
joinedload(SeasonRequest.requested_by),
|
||||
@@ -366,7 +322,6 @@ class TvRepository:
|
||||
joinedload(SeasonRequest.season).joinedload(Season.show),
|
||||
)
|
||||
results = self.db.execute(stmt).scalars().unique().all()
|
||||
log.info(f"Successfully retrieved {len(results)} season requests.")
|
||||
return [
|
||||
RichSeasonRequestSchema(
|
||||
id=x.id,
|
||||
@@ -394,17 +349,11 @@ class TvRepository:
|
||||
:raises IntegrityError: If the record violates constraints.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Adding season file: {season_file.model_dump_json()}")
|
||||
db_model = SeasonFile(**season_file.model_dump())
|
||||
try:
|
||||
self.db.add(db_model)
|
||||
self.db.commit()
|
||||
self.db.refresh(db_model)
|
||||
# Assuming SeasonFile model has an 'id' attribute after refresh for logging.
|
||||
# If not, this line or the model needs adjustment.
|
||||
log.info(
|
||||
f"Successfully added season file. Torrent ID: {db_model.torrent_id}, Path: {db_model.file_path_suffix}"
|
||||
)
|
||||
return SeasonFileSchema.model_validate(db_model)
|
||||
except IntegrityError as e:
|
||||
self.db.rollback()
|
||||
@@ -423,16 +372,12 @@ class TvRepository:
|
||||
:return: The number of season files removed.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to remove season files for torrent_id: {torrent_id}")
|
||||
try:
|
||||
stmt = delete(SeasonFile).where(SeasonFile.torrent_id == torrent_id)
|
||||
result = self.db.execute(stmt)
|
||||
self.db.commit()
|
||||
deleted_count = result.rowcount # rowcount is an int, not a callable
|
||||
log.info(
|
||||
f"Successfully removed {deleted_count} season files for torrent_id: {torrent_id}"
|
||||
)
|
||||
return deleted_count()
|
||||
return deleted_count
|
||||
except SQLAlchemyError as e:
|
||||
self.db.rollback()
|
||||
log.error(
|
||||
@@ -449,15 +394,12 @@ class TvRepository:
|
||||
:raises NotFoundError: If the show with the given ID is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Setting library for show_id {show_id} to {library}")
|
||||
try:
|
||||
show = self.db.get(Show, show_id)
|
||||
if not show:
|
||||
log.warning(f"Show with id {show_id} not found.")
|
||||
raise NotFoundError(f"Show with id {show_id} not found.")
|
||||
show.library = library
|
||||
self.db.commit()
|
||||
log.info(f"Successfully set library for show_id {show_id} to {library}")
|
||||
except SQLAlchemyError as e:
|
||||
self.db.rollback()
|
||||
log.error(f"Database error setting library for show {show_id}: {e}")
|
||||
@@ -473,13 +415,9 @@ class TvRepository:
|
||||
:return: A list of SeasonFile objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve season files for season_id: {season_id}")
|
||||
try:
|
||||
stmt = select(SeasonFile).where(SeasonFile.season_id == season_id)
|
||||
results = self.db.execute(stmt).scalars().all()
|
||||
log.info(
|
||||
f"Successfully retrieved {len(results)} season files for season_id: {season_id}"
|
||||
)
|
||||
return [SeasonFileSchema.model_validate(sf) for sf in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -495,7 +433,6 @@ class TvRepository:
|
||||
:return: A list of Torrent objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve torrents for show_id: {show_id}")
|
||||
try:
|
||||
stmt = (
|
||||
select(Torrent)
|
||||
@@ -505,9 +442,6 @@ class TvRepository:
|
||||
.where(Season.show_id == show_id)
|
||||
)
|
||||
results = self.db.execute(stmt).scalars().unique().all()
|
||||
log.info(
|
||||
f"Successfully retrieved {len(results)} torrents for show_id: {show_id}"
|
||||
)
|
||||
return [TorrentSchema.model_validate(torrent) for torrent in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error retrieving torrents for show_id {show_id}: {e}")
|
||||
@@ -520,7 +454,6 @@ class TvRepository:
|
||||
:return: A list of Show objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug("Attempting to retrieve all shows with torrents.")
|
||||
try:
|
||||
stmt = (
|
||||
select(Show)
|
||||
@@ -532,7 +465,6 @@ class TvRepository:
|
||||
.order_by(Show.name)
|
||||
)
|
||||
results = self.db.execute(stmt).scalars().unique().all()
|
||||
log.info(f"Successfully retrieved {len(results)} shows with torrents.")
|
||||
return [ShowSchema.model_validate(show) for show in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error retrieving all shows with torrents: {e}")
|
||||
@@ -546,7 +478,6 @@ class TvRepository:
|
||||
:return: A list of SeasonNumber objects.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve season numbers for torrent_id: {torrent_id}")
|
||||
try:
|
||||
stmt = (
|
||||
select(Season.number)
|
||||
@@ -555,9 +486,6 @@ class TvRepository:
|
||||
.where(SeasonFile.torrent_id == torrent_id)
|
||||
)
|
||||
results = self.db.execute(stmt).scalars().unique().all()
|
||||
log.info(
|
||||
f"Successfully retrieved {len(results)} season numbers for torrent_id: {torrent_id}"
|
||||
)
|
||||
return [SeasonNumber(x) for x in results]
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -576,7 +504,6 @@ class TvRepository:
|
||||
:raises NotFoundError: If the season request is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve season request with id: {season_request_id}")
|
||||
try:
|
||||
request = self.db.get(SeasonRequest, season_request_id)
|
||||
if not request:
|
||||
@@ -584,9 +511,6 @@ class TvRepository:
|
||||
raise NotFoundError(
|
||||
f"Season request with id {season_request_id} not found."
|
||||
)
|
||||
log.info(
|
||||
f"Successfully retrieved season request with id: {season_request_id}"
|
||||
)
|
||||
return SeasonRequestSchema.model_validate(request)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(
|
||||
@@ -603,7 +527,6 @@ class TvRepository:
|
||||
:raises NotFoundError: If the show for the given season ID is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to retrieve show by season_id: {season_id}")
|
||||
try:
|
||||
stmt = (
|
||||
select(Show)
|
||||
@@ -613,9 +536,7 @@ class TvRepository:
|
||||
)
|
||||
result = self.db.execute(stmt).unique().scalar_one_or_none()
|
||||
if not result:
|
||||
log.warning(f"Show for season_id {season_id} not found.")
|
||||
raise NotFoundError(f"Show for season_id {season_id} not found.")
|
||||
log.info(f"Successfully retrieved show for season_id: {season_id}")
|
||||
return ShowSchema.model_validate(result)
|
||||
except SQLAlchemyError as e:
|
||||
log.error(f"Database error retrieving show by season_id {season_id}: {e}")
|
||||
@@ -634,10 +555,8 @@ class TvRepository:
|
||||
:raises NotFoundError: If the show is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to add season {season_data.number} to show {show_id}")
|
||||
db_show = self.db.get(Show, show_id)
|
||||
if not db_show:
|
||||
log.warning(f"Show with id {show_id} not found when trying to add season.")
|
||||
raise NotFoundError(f"Show with id {show_id} not found.")
|
||||
|
||||
stmt = (
|
||||
@@ -647,9 +566,6 @@ class TvRepository:
|
||||
)
|
||||
existing_db_season = self.db.execute(stmt).scalar_one_or_none()
|
||||
if existing_db_season:
|
||||
log.info(
|
||||
f"Season {season_data.number} already exists for show {show_id} (ID: {existing_db_season.id}). Skipping add."
|
||||
)
|
||||
return SeasonSchema.model_validate(existing_db_season)
|
||||
|
||||
db_season = Season(
|
||||
@@ -674,9 +590,6 @@ class TvRepository:
|
||||
self.db.add(db_season)
|
||||
self.db.commit()
|
||||
self.db.refresh(db_season)
|
||||
log.info(
|
||||
f"Successfully added season {db_season.number} (ID: {db_season.id}) to show {show_id}."
|
||||
)
|
||||
return SeasonSchema.model_validate(db_season)
|
||||
|
||||
def add_episode_to_season(
|
||||
@@ -692,14 +605,8 @@ class TvRepository:
|
||||
:raises NotFoundError: If the season is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(
|
||||
f"Attempting to add episode {episode_data.number} to season {season_id}"
|
||||
)
|
||||
db_season = self.db.get(Season, season_id)
|
||||
if not db_season:
|
||||
log.warning(
|
||||
f"Season with id {season_id} not found when trying to add episode."
|
||||
)
|
||||
raise NotFoundError(f"Season with id {season_id} not found.")
|
||||
|
||||
stmt = (
|
||||
@@ -709,9 +616,6 @@ class TvRepository:
|
||||
)
|
||||
existing_db_episode = self.db.execute(stmt).scalar_one_or_none()
|
||||
if existing_db_episode:
|
||||
log.info(
|
||||
f"Episode {episode_data.number} already exists for season {season_id} (ID: {existing_db_episode.id}). Skipping add."
|
||||
)
|
||||
return EpisodeSchema.model_validate(existing_db_episode)
|
||||
|
||||
db_episode = Episode(
|
||||
@@ -725,9 +629,6 @@ class TvRepository:
|
||||
self.db.add(db_episode)
|
||||
self.db.commit()
|
||||
self.db.refresh(db_episode)
|
||||
log.info(
|
||||
f"Successfully added episode {db_episode.number} (ID: {db_episode.id}) to season {season_id}."
|
||||
)
|
||||
return EpisodeSchema.model_validate(db_episode)
|
||||
|
||||
def update_show_attributes(
|
||||
@@ -749,10 +650,8 @@ class TvRepository:
|
||||
:param ended: The new ended status for the show.
|
||||
:return: The updated ShowSchema object.
|
||||
"""
|
||||
log.debug(f"Attempting to update attributes for show ID: {show_id}")
|
||||
db_show = self.db.get(Show, show_id)
|
||||
if not db_show:
|
||||
log.warning(f"Show with id {show_id} not found for attribute update.")
|
||||
raise NotFoundError(f"Show with id {show_id} not found.")
|
||||
|
||||
updated = False
|
||||
@@ -774,13 +673,9 @@ class TvRepository:
|
||||
):
|
||||
db_show.continuous_download = continuous_download
|
||||
updated = True
|
||||
|
||||
if updated:
|
||||
self.db.commit()
|
||||
self.db.refresh(db_show)
|
||||
log.info(f"Successfully updated attributes for show ID: {show_id}")
|
||||
else:
|
||||
log.info(f"No attribute changes needed for show ID: {show_id}")
|
||||
return ShowSchema.model_validate(db_show)
|
||||
|
||||
def update_season_attributes(
|
||||
@@ -797,10 +692,8 @@ class TvRepository:
|
||||
:raises NotFoundError: If the season is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to update attributes for season ID: {season_id}")
|
||||
db_season = self.db.get(Season, season_id)
|
||||
if not db_season:
|
||||
log.warning(f"Season with id {season_id} not found for attribute update.")
|
||||
raise NotFoundError(f"Season with id {season_id} not found.")
|
||||
|
||||
updated = False
|
||||
@@ -814,9 +707,6 @@ class TvRepository:
|
||||
if updated:
|
||||
self.db.commit()
|
||||
self.db.refresh(db_season)
|
||||
log.info(f"Successfully updated attributes for season ID: {season_id}")
|
||||
else:
|
||||
log.info(f"No attribute changes needed for season ID: {season_id}")
|
||||
return SeasonSchema.model_validate(db_season)
|
||||
|
||||
def update_episode_attributes(
|
||||
@@ -832,10 +722,8 @@ class TvRepository:
|
||||
:raises NotFoundError: If the episode is not found.
|
||||
:raises SQLAlchemyError: If a database error occurs.
|
||||
"""
|
||||
log.debug(f"Attempting to update attributes for episode ID: {episode_id}")
|
||||
db_episode = self.db.get(Episode, episode_id)
|
||||
if not db_episode:
|
||||
log.warning(f"Episode with id {episode_id} not found for attribute update.")
|
||||
raise NotFoundError(f"Episode with id {episode_id} not found.")
|
||||
|
||||
updated = False
|
||||
@@ -846,7 +734,4 @@ class TvRepository:
|
||||
if updated:
|
||||
self.db.commit()
|
||||
self.db.refresh(db_episode)
|
||||
log.info(f"Successfully updated attributes for episode ID: {episode_id}")
|
||||
else:
|
||||
log.info(f"No attribute changes needed for episode ID: {episode_id}")
|
||||
return EpisodeSchema.model_validate(db_episode)
|
||||
|
||||
@@ -257,13 +257,11 @@ def request_a_season(
|
||||
"""
|
||||
adds request flag to a season
|
||||
"""
|
||||
log.info(f"Got season request: {season_request.model_dump()}")
|
||||
request: SeasonRequest = SeasonRequest.model_validate(season_request)
|
||||
request.requested_by = UserRead.model_validate(user)
|
||||
if user.is_superuser:
|
||||
request.authorized = True
|
||||
request.authorized_by = UserRead.model_validate(user)
|
||||
log.info(f"Adding season request: {request.model_dump()}")
|
||||
tv_service.add_season_request(request)
|
||||
return
|
||||
|
||||
|
||||
@@ -194,9 +194,6 @@ class TvService:
|
||||
:param search_query_override: Optional override for the search query.
|
||||
:return: A list of indexer query results.
|
||||
"""
|
||||
log.debug(
|
||||
f"getting all available torrents for season {season_number} for show {show_id}"
|
||||
)
|
||||
show = self.tv_repository.get_show_by_id(show_id=show_id)
|
||||
if search_query_override:
|
||||
search_query = search_query_override
|
||||
@@ -209,9 +206,6 @@ class TvService:
|
||||
)
|
||||
|
||||
if search_query_override:
|
||||
log.debug(
|
||||
f"Found with search query override {torrents.__len__()} torrents: {torrents}"
|
||||
)
|
||||
return torrents
|
||||
|
||||
result: list[IndexerQueryResult] = []
|
||||
@@ -466,9 +460,6 @@ class TvService:
|
||||
:raises ValueError: If the season request is not authorized.
|
||||
"""
|
||||
if not season_request.authorized:
|
||||
log.error(
|
||||
f"Season request {season_request.id} is not authorized for download"
|
||||
)
|
||||
raise ValueError(
|
||||
f"Season request {season_request.id} is not authorized for download"
|
||||
)
|
||||
@@ -570,18 +561,11 @@ class TvService:
|
||||
|
||||
# import subtitles
|
||||
for subtitle_file in subtitle_files:
|
||||
log.debug(
|
||||
f"Searching for pattern {subtitle_pattern} in subtitle file: {subtitle_file.name}"
|
||||
)
|
||||
regex_result = re.search(
|
||||
subtitle_pattern, subtitle_file.name, re.IGNORECASE
|
||||
)
|
||||
if regex_result:
|
||||
language_code = regex_result.group(1)
|
||||
log.debug(
|
||||
f"Found matching pattern: {subtitle_pattern} in subtitle file: {subtitle_file.name},"
|
||||
+ f" extracted language code: {language_code}"
|
||||
)
|
||||
target_subtitle_file = target_file_name.with_suffix(
|
||||
f".{language_code}.srt"
|
||||
)
|
||||
@@ -593,9 +577,7 @@ class TvService:
|
||||
|
||||
# import episode videos
|
||||
for file in video_files:
|
||||
log.debug(f"Searching for pattern {pattern} in video file: {file.name}")
|
||||
if re.search(pattern, file.name, re.IGNORECASE):
|
||||
log.debug(f"Found matching pattern: {pattern} in file {file.name}")
|
||||
target_video_file = target_file_name.with_suffix(file.suffix)
|
||||
import_file(target_file=target_video_file, source_file=file)
|
||||
return True
|
||||
@@ -875,9 +857,7 @@ class TvService:
|
||||
try:
|
||||
source_directory.rename(new_source_path)
|
||||
except Exception as e:
|
||||
log.error(
|
||||
f"Failed to rename {source_directory} to {new_source_path}: {e}"
|
||||
)
|
||||
log.error(f"Failed to rename {source_directory} to {new_source_path}: {e}")
|
||||
|
||||
|
||||
def auto_download_all_approved_season_requests() -> None:
|
||||
@@ -898,7 +878,6 @@ def auto_download_all_approved_season_requests() -> None:
|
||||
log.info("Auto downloading all approved season requests")
|
||||
season_requests = tv_repository.get_season_requests()
|
||||
log.info(f"Found {len(season_requests)} season requests to process")
|
||||
log.debug(f"Season requests: {[x.model_dump() for x in season_requests]}")
|
||||
count = 0
|
||||
|
||||
for season_request in season_requests:
|
||||
@@ -998,7 +977,7 @@ def update_all_non_ended_shows_metadata() -> None:
|
||||
if show.continuous_download:
|
||||
for new_season in new_seasons:
|
||||
log.info(
|
||||
f"Automatically adding season requeest for new season {new_season.number} of show {updated_show.name}"
|
||||
f"Automatically adding season request for new season {new_season.number} of show {updated_show.name}"
|
||||
)
|
||||
tv_service.add_season_request(
|
||||
SeasonRequest(
|
||||
@@ -1010,7 +989,6 @@ def update_all_non_ended_shows_metadata() -> None:
|
||||
)
|
||||
|
||||
if updated_show:
|
||||
log.info(f"Successfully updated metadata for show: {updated_show.name}")
|
||||
log.debug(
|
||||
f"Added new seasons: {len(new_seasons)} to show: {updated_show.name}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user