e45465d52d
Destination resolution
- Replace the single ResolveDestinationUseCase with four dedicated
functions, one per release type:
resolve_season_destination (pack season, folder move)
resolve_episode_destination (single episode, file move)
resolve_movie_destination (movie, file move)
resolve_series_destination (multi-season pack, folder move)
- Each returns a dedicated DTO carrying only the fields relevant to
that release type — no more polymorphic ResolvedDestination with
half the fields unused depending on the case.
- Looser series folder matching: exact computed-name match is reused
silently; any deviation (different group, multiple candidates) now
prompts the user with all options including the computed name.
Agent tools
- Four new tools wrapping the use cases above; old resolve_destination
removed from the registry.
- New move_to_destination tool: create_folder + move, chained — used
after a resolve_* call to perform the actual relocation.
- Low-level filesystem_operations module (create_folder, move via mv)
for instant same-FS renames (ZFS).
Prompt & persona
- New PromptBuilder (alfred/agent/prompt.py) replacing prompts.py:
identity + personality block, situational expressions, memory
schema, episodic/STM/config context, tool catalogue.
- Per-user expression system: knowledge/users/common.yaml +
{username}.yaml are merged at runtime; one phrase per situation
(greeting/success/error/...) is sampled into the system prompt.
qBittorrent integration
- Credentials now come from settings (qbittorrent_url/username/password)
instead of hardcoded defaults.
- New client methods: find_by_name, set_location, recheck — the trio
needed to update a torrent's save path and re-verify after a move.
- Host→container path translation settings (qbittorrent_host_path /
qbittorrent_container_path) for docker-mounted setups.
Subtitles
- Identifier: strip parenthesized qualifiers (simplified, brazil…) at
tokenization; new _tokenize_suffix used for the episode_subfolder
pattern so episode-stem tokens no longer pollute language detection.
- Placer: extract _build_dest_name so it can be reused by the new
dry_run path in ManageSubtitlesUseCase.
- Knowledge: add yue, ell, ind, msa, rus, vie, heb, tam, tel, tha,
hin, ukr; add 'fre' to fra; add 'simplified'/'traditional' to zho.
Misc
- LTM workspace: add 'trash' folder slot.
- Default LLM provider switched to deepseek.
- testing/debug_release.py: CLI to parse a release, hit TMDB, and
dry-run the destination resolution end-to-end.
214 lines
5.9 KiB
Python
214 lines
5.9 KiB
Python
"""Filesystem application DTOs."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class CopyMediaResponse:
|
|
"""Response from copying a media file."""
|
|
|
|
status: str
|
|
source: str | None = None
|
|
destination: str | None = None
|
|
filename: str | None = None
|
|
size: int | None = None
|
|
error: str | None = None
|
|
message: str | None = None
|
|
|
|
def to_dict(self) -> dict:
|
|
if self.error:
|
|
return {"status": self.status, "error": self.error, "message": self.message}
|
|
return {
|
|
"status": self.status,
|
|
"source": self.source,
|
|
"destination": self.destination,
|
|
"filename": self.filename,
|
|
"size": self.size,
|
|
}
|
|
|
|
|
|
@dataclass
|
|
class MoveMediaResponse:
|
|
"""Response from moving a media file."""
|
|
|
|
status: str
|
|
source: str | None = None
|
|
destination: str | None = None
|
|
filename: str | None = None
|
|
size: int | None = None
|
|
error: str | None = None
|
|
message: str | None = None
|
|
|
|
def to_dict(self) -> dict:
|
|
if self.error:
|
|
return {"status": self.status, "error": self.error, "message": self.message}
|
|
return {
|
|
"status": self.status,
|
|
"source": self.source,
|
|
"destination": self.destination,
|
|
"filename": self.filename,
|
|
"size": self.size,
|
|
}
|
|
|
|
|
|
@dataclass
|
|
class SetFolderPathResponse:
|
|
"""Response from setting a folder path."""
|
|
|
|
status: str
|
|
folder_name: str | None = None
|
|
path: str | None = None
|
|
error: str | None = None
|
|
message: str | None = None
|
|
|
|
def to_dict(self):
|
|
"""Convert to dict for agent compatibility."""
|
|
result = {"status": self.status}
|
|
|
|
if self.error:
|
|
result["error"] = self.error
|
|
result["message"] = self.message
|
|
else:
|
|
if self.folder_name:
|
|
result["folder_name"] = self.folder_name
|
|
if self.path:
|
|
result["path"] = self.path
|
|
|
|
return result
|
|
|
|
|
|
@dataclass
|
|
class PlacedSubtitle:
|
|
"""One subtitle file successfully placed."""
|
|
|
|
source: str
|
|
destination: str
|
|
filename: str
|
|
|
|
def to_dict(self) -> dict:
|
|
return {
|
|
"source": self.source,
|
|
"destination": self.destination,
|
|
"filename": self.filename,
|
|
}
|
|
|
|
|
|
@dataclass
|
|
class UnresolvedTrack:
|
|
"""A subtitle track that needs agent clarification before placement."""
|
|
|
|
raw_tokens: list[str]
|
|
file_path: str | None = None
|
|
file_size_kb: float | None = None
|
|
reason: str = "" # "unknown_language" | "low_confidence"
|
|
|
|
def to_dict(self) -> dict:
|
|
return {
|
|
"raw_tokens": self.raw_tokens,
|
|
"file_path": self.file_path,
|
|
"file_size_kb": self.file_size_kb,
|
|
"reason": self.reason,
|
|
}
|
|
|
|
|
|
@dataclass
|
|
class AvailableSubtitle:
|
|
"""One subtitle track available on an embedded media item."""
|
|
|
|
language: str # ISO 639-2 code
|
|
subtitle_type: str # "standard" | "sdh" | "forced" | "unknown"
|
|
|
|
def to_dict(self) -> dict:
|
|
return {"language": self.language, "type": self.subtitle_type}
|
|
|
|
|
|
@dataclass
|
|
class ManageSubtitlesResponse:
|
|
"""Response from the manage_subtitles use case."""
|
|
|
|
status: str # "ok" | "needs_clarification" | "error"
|
|
video_path: str | None = None
|
|
placed: list[PlacedSubtitle] | None = None
|
|
skipped_count: int = 0
|
|
unresolved: list[UnresolvedTrack] | None = None
|
|
available: list[AvailableSubtitle] | None = None # embedded tracks summary
|
|
error: str | None = None
|
|
message: str | None = None
|
|
|
|
def to_dict(self) -> dict:
|
|
if self.error:
|
|
return {"status": self.status, "error": self.error, "message": self.message}
|
|
result = {
|
|
"status": self.status,
|
|
"video_path": self.video_path,
|
|
"placed": [p.to_dict() for p in (self.placed or [])],
|
|
"placed_count": len(self.placed or []),
|
|
"skipped_count": self.skipped_count,
|
|
}
|
|
if self.unresolved:
|
|
result["unresolved"] = [u.to_dict() for u in self.unresolved]
|
|
result["unresolved_count"] = len(self.unresolved)
|
|
if self.available:
|
|
result["available"] = [a.to_dict() for a in self.available]
|
|
return result
|
|
|
|
|
|
@dataclass
|
|
class CreateSeedLinksResponse:
|
|
"""Response from creating seed links for a torrent."""
|
|
|
|
status: str
|
|
torrent_subfolder: str | None = None
|
|
linked_file: str | None = None
|
|
copied_files: list[str] | None = None
|
|
copied_count: int = 0
|
|
skipped: list[str] | None = None
|
|
error: str | None = None
|
|
message: str | None = None
|
|
|
|
def to_dict(self) -> dict:
|
|
if self.error:
|
|
return {"status": self.status, "error": self.error, "message": self.message}
|
|
return {
|
|
"status": self.status,
|
|
"torrent_subfolder": self.torrent_subfolder,
|
|
"linked_file": self.linked_file,
|
|
"copied_files": self.copied_files or [],
|
|
"copied_count": self.copied_count,
|
|
"skipped": self.skipped or [],
|
|
}
|
|
|
|
|
|
@dataclass
|
|
class ListFolderResponse:
|
|
"""Response from listing a folder."""
|
|
|
|
status: str
|
|
folder_type: str | None = None
|
|
path: str | None = None
|
|
entries: list[str] | None = None
|
|
count: int | None = None
|
|
error: str | None = None
|
|
message: str | None = None
|
|
|
|
def to_dict(self):
|
|
"""Convert to dict for agent compatibility."""
|
|
result = {"status": self.status}
|
|
|
|
if self.error:
|
|
result["error"] = self.error
|
|
result["message"] = self.message
|
|
else:
|
|
if self.folder_type:
|
|
result["folder_type"] = self.folder_type
|
|
if self.path:
|
|
result["path"] = self.path
|
|
if self.entries is not None:
|
|
result["entries"] = self.entries
|
|
if self.count is not None:
|
|
result["count"] = self.count
|
|
|
|
return result
|