chore: apply pre-commit auto-fixes (trim trailing whitespace, EOF)
This commit is contained in:
@@ -29,7 +29,9 @@ def _sanitize(text: str) -> str:
|
||||
return _WIN_FORBIDDEN.sub("", text)
|
||||
|
||||
|
||||
def _find_existing_tvshow_folders(tv_root: Path, tmdb_title: str, tmdb_year: int) -> list[str]:
|
||||
def _find_existing_tvshow_folders(
|
||||
tv_root: Path, tmdb_title: str, tmdb_year: int
|
||||
) -> list[str]:
|
||||
"""Return folder names in tv_root that match title + year prefix."""
|
||||
if not tv_root.exists():
|
||||
return []
|
||||
@@ -52,9 +54,11 @@ def _get_tv_root() -> Path | None:
|
||||
# Internal sentinel + series-folder resolver (shared by the 3 TV use cases)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@dataclass
|
||||
class _Clarification:
|
||||
"""Module-private sentinel signalling that user input is needed."""
|
||||
|
||||
question: str
|
||||
options: list[str]
|
||||
|
||||
@@ -99,6 +103,7 @@ def _resolve_series_folder(
|
||||
# DTOs
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@dataclass
|
||||
class _ResolvedDestinationBase:
|
||||
"""
|
||||
@@ -109,7 +114,7 @@ class _ResolvedDestinationBase:
|
||||
and a to_dict() that delegates the non-ok cases via _base_dict().
|
||||
"""
|
||||
|
||||
status: str # "ok" | "needs_clarification" | "error"
|
||||
status: str # "ok" | "needs_clarification" | "error"
|
||||
|
||||
# needs_clarification
|
||||
question: str | None = None
|
||||
@@ -124,7 +129,11 @@ class _ResolvedDestinationBase:
|
||||
if self.status == "error":
|
||||
return {"status": self.status, "error": self.error, "message": self.message}
|
||||
if self.status == "needs_clarification":
|
||||
return {"status": self.status, "question": self.question, "options": self.options or []}
|
||||
return {
|
||||
"status": self.status,
|
||||
"question": self.question,
|
||||
"options": self.options or [],
|
||||
}
|
||||
return None
|
||||
|
||||
|
||||
@@ -155,7 +164,7 @@ class ResolvedEpisodeDestination(_ResolvedDestinationBase):
|
||||
|
||||
series_folder: str | None = None
|
||||
season_folder: str | None = None
|
||||
library_file: str | None = None # full path to destination .mkv
|
||||
library_file: str | None = None # full path to destination .mkv
|
||||
series_folder_name: str | None = None
|
||||
season_folder_name: str | None = None
|
||||
filename: str | None = None
|
||||
@@ -216,6 +225,7 @@ class ResolvedSeriesDestination(_ResolvedDestinationBase):
|
||||
# Use cases
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def resolve_season_destination(
|
||||
release_name: str,
|
||||
tmdb_title: str,
|
||||
@@ -231,14 +241,17 @@ def resolve_season_destination(
|
||||
tv_root = _get_tv_root()
|
||||
if not tv_root:
|
||||
return ResolvedSeasonDestination(
|
||||
status="error", error="library_not_set",
|
||||
status="error",
|
||||
error="library_not_set",
|
||||
message="TV show library path is not configured.",
|
||||
)
|
||||
|
||||
parsed = parse_release(release_name)
|
||||
computed_name = _sanitize(parsed.show_folder_name(tmdb_title, tmdb_year))
|
||||
|
||||
resolved = _resolve_series_folder(tv_root, tmdb_title, tmdb_year, computed_name, confirmed_folder)
|
||||
resolved = _resolve_series_folder(
|
||||
tv_root, tmdb_title, tmdb_year, computed_name, confirmed_folder
|
||||
)
|
||||
if isinstance(resolved, _Clarification):
|
||||
return ResolvedSeasonDestination(
|
||||
status="needs_clarification",
|
||||
@@ -277,7 +290,8 @@ def resolve_episode_destination(
|
||||
tv_root = _get_tv_root()
|
||||
if not tv_root:
|
||||
return ResolvedEpisodeDestination(
|
||||
status="error", error="library_not_set",
|
||||
status="error",
|
||||
error="library_not_set",
|
||||
message="TV show library path is not configured.",
|
||||
)
|
||||
|
||||
@@ -285,7 +299,9 @@ def resolve_episode_destination(
|
||||
ext = Path(source_file).suffix
|
||||
computed_name = _sanitize(parsed.show_folder_name(tmdb_title, tmdb_year))
|
||||
|
||||
resolved = _resolve_series_folder(tv_root, tmdb_title, tmdb_year, computed_name, confirmed_folder)
|
||||
resolved = _resolve_series_folder(
|
||||
tv_root, tmdb_title, tmdb_year, computed_name, confirmed_folder
|
||||
)
|
||||
if isinstance(resolved, _Clarification):
|
||||
return ResolvedEpisodeDestination(
|
||||
status="needs_clarification",
|
||||
@@ -328,7 +344,8 @@ def resolve_movie_destination(
|
||||
movies_root = memory.ltm.library_paths.get("movie")
|
||||
if not movies_root:
|
||||
return ResolvedMovieDestination(
|
||||
status="error", error="library_not_set",
|
||||
status="error",
|
||||
error="library_not_set",
|
||||
message="Movie library path is not configured.",
|
||||
)
|
||||
|
||||
@@ -365,14 +382,17 @@ def resolve_series_destination(
|
||||
tv_root = _get_tv_root()
|
||||
if not tv_root:
|
||||
return ResolvedSeriesDestination(
|
||||
status="error", error="library_not_set",
|
||||
status="error",
|
||||
error="library_not_set",
|
||||
message="TV show library path is not configured.",
|
||||
)
|
||||
|
||||
parsed = parse_release(release_name)
|
||||
computed_name = _sanitize(parsed.show_folder_name(tmdb_title, tmdb_year))
|
||||
|
||||
resolved = _resolve_series_folder(tv_root, tmdb_title, tmdb_year, computed_name, confirmed_folder)
|
||||
resolved = _resolve_series_folder(
|
||||
tv_root, tmdb_title, tmdb_year, computed_name, confirmed_folder
|
||||
)
|
||||
if isinstance(resolved, _Clarification):
|
||||
return ResolvedSeriesDestination(
|
||||
status="needs_clarification",
|
||||
|
||||
Reference in New Issue
Block a user