mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:43:28 +02:00
fix: rename source directory before importing existing movies and TV shows
This commit is contained in:
@@ -654,8 +654,17 @@ class MovieService:
|
||||
return import_candidates
|
||||
|
||||
def import_existing_movie(self, movie: Movie, source_directory: Path) -> bool:
|
||||
new_source_path = source_directory.parent / ("." + source_directory.name)
|
||||
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}"
|
||||
)
|
||||
raise Exception("Failed to rename directory") from e
|
||||
|
||||
video_files, subtitle_files, all_files = get_files_for_import(
|
||||
directory=source_directory
|
||||
directory=new_source_path
|
||||
)
|
||||
|
||||
success = self.import_movie(
|
||||
@@ -674,15 +683,6 @@ class MovieService:
|
||||
)
|
||||
)
|
||||
|
||||
new_source_path = source_directory.parent / ("." + source_directory.name)
|
||||
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}"
|
||||
)
|
||||
return False
|
||||
|
||||
return success
|
||||
|
||||
def update_movie_metadata(
|
||||
|
||||
@@ -888,8 +888,15 @@ class TvService:
|
||||
return import_candidates
|
||||
|
||||
def import_existing_tv_show(self, tv_show: Show, source_directory: Path) -> None:
|
||||
new_source_path = source_directory.parent / ("." + source_directory.name)
|
||||
try:
|
||||
source_directory.rename(new_source_path)
|
||||
except Exception as e:
|
||||
log.error(f"Failed to rename {source_directory} to {new_source_path}: {e}")
|
||||
raise Exception("Failed to rename source directory") from e
|
||||
|
||||
video_files, subtitle_files, all_files = get_files_for_import(
|
||||
directory=source_directory
|
||||
directory=new_source_path
|
||||
)
|
||||
for season in tv_show.seasons:
|
||||
success, imported_episode_count = self.import_season(
|
||||
@@ -908,12 +915,6 @@ class TvService:
|
||||
if success or imported_episode_count > (len(season.episodes) / 2):
|
||||
self.tv_repository.add_season_file(season_file=season_file)
|
||||
|
||||
new_source_path = source_directory.parent / ("." + source_directory.name)
|
||||
try:
|
||||
source_directory.rename(new_source_path)
|
||||
except Exception as e:
|
||||
log.error(f"Failed to rename {source_directory} to {new_source_path}: {e}")
|
||||
|
||||
def get_importable_tv_shows(
|
||||
self, metadata_provider: AbstractMetadataProvider
|
||||
) -> list[MediaImportSuggestion]:
|
||||
|
||||
Reference in New Issue
Block a user