249c5de76a
- Refactor memory system (episodic/STM/LTM with components) - Implement complete subtitle domain (scanner, matcher, placer) - Add YAML workflow infrastructure - Externalize knowledge base (patterns, release groups) - Add comprehensive testing suite - Create manual testing CLIs
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
"""CreateSeedLinksUseCase — prepares a torrent folder for continued seeding."""
|
|
|
|
import logging
|
|
|
|
from alfred.infrastructure.filesystem import FileManager
|
|
from alfred.infrastructure.persistence import get_memory
|
|
|
|
from .dto import CreateSeedLinksResponse
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class CreateSeedLinksUseCase:
|
|
"""
|
|
Prepares a torrent subfolder so qBittorrent can keep seeding after a move.
|
|
|
|
Hard-links the video file from the library back into torrents/<original_folder>/,
|
|
then copies all remaining files from the original download folder (subs, nfo, …).
|
|
"""
|
|
|
|
def __init__(self, file_manager: FileManager):
|
|
self.file_manager = file_manager
|
|
|
|
def execute(
|
|
self, library_file: str, original_download_folder: str
|
|
) -> CreateSeedLinksResponse:
|
|
memory = get_memory()
|
|
torrent_folder = memory.ltm.workspace.torrent
|
|
|
|
if not torrent_folder:
|
|
return CreateSeedLinksResponse(
|
|
status="error",
|
|
error="torrent_folder_not_set",
|
|
message="Torrent folder is not configured. Use set_path_for_folder to set it.",
|
|
)
|
|
|
|
result = self.file_manager.create_seed_links(
|
|
library_file, original_download_folder, torrent_folder
|
|
)
|
|
|
|
if result.get("status") == "ok":
|
|
return CreateSeedLinksResponse(
|
|
status="ok",
|
|
torrent_subfolder=result.get("torrent_subfolder"),
|
|
linked_file=result.get("linked_file"),
|
|
copied_files=result.get("copied_files"),
|
|
copied_count=result.get("copied_count", 0),
|
|
skipped=result.get("skipped"),
|
|
)
|
|
return CreateSeedLinksResponse(
|
|
status="error",
|
|
error=result.get("error"),
|
|
message=result.get("message"),
|
|
)
|