mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-02-20 07:59:50 -05:00
return error on failed movie import
This commit is contained in:
@@ -15,7 +15,6 @@ from media_manager.schemas import MediaImportSuggestion
|
||||
from media_manager.torrent.utils import detect_unknown_media
|
||||
from media_manager.torrent.schemas import Torrent
|
||||
from media_manager.movies import log
|
||||
from media_manager.exceptions import MediaAlreadyExists
|
||||
from media_manager.movies.schemas import (
|
||||
Movie,
|
||||
MovieRequest,
|
||||
@@ -114,7 +113,11 @@ def import_detected_movie(
|
||||
):
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "No such directory")
|
||||
movie = movie_service.get_movie_by_id(movie_id=movie_id)
|
||||
movie_service.import_existing_movie(movie=movie, source_directory=source_directory)
|
||||
success = movie_service.import_existing_movie(
|
||||
movie=movie, source_directory=source_directory
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "Error on importing")
|
||||
|
||||
|
||||
@router.get(
|
||||
|
||||
@@ -600,7 +600,7 @@ class MovieService:
|
||||
)
|
||||
return import_candidates
|
||||
|
||||
def import_existing_movie(self, movie: Movie, source_directory: Path) -> None:
|
||||
def import_existing_movie(self, movie: Movie, source_directory: Path) -> bool:
|
||||
video_files, subtitle_files, all_files = get_files_for_import(
|
||||
directory=source_directory
|
||||
)
|
||||
@@ -612,11 +612,19 @@ class MovieService:
|
||||
file_path_suffix="IMPORTED",
|
||||
)
|
||||
if success:
|
||||
self.movie_repository.add_movie_file(MovieFile(movie_id=movie.id,file_path_suffix="IMPORTED", torrent_id=None, quality=Quality.unknown))
|
||||
self.movie_repository.add_movie_file(
|
||||
MovieFile(
|
||||
movie_id=movie.id,
|
||||
file_path_suffix="IMPORTED",
|
||||
torrent_id=None,
|
||||
quality=Quality.unknown,
|
||||
)
|
||||
)
|
||||
|
||||
new_source_path = source_directory.parent / ("." + source_directory.name)
|
||||
source_directory.rename(new_source_path)
|
||||
|
||||
return success
|
||||
|
||||
def update_movie_metadata(
|
||||
self, db_movie: Movie, metadata_provider: AbstractMetadataProvider
|
||||
|
||||
Reference in New Issue
Block a user