Fix: Add graceful download cancellation on Ctrl+C

- Add cancellation flag to AniworldLoader with request_cancel/reset_cancel/is_cancelled methods
- Update base_provider.Loader interface with cancellation abstract methods
- Integrate cancellation check in YT-DLP progress hooks
- Add request_download_cancel method to SeriesApp and AnimeService
- Update DownloadService.stop() to request cancellation before shutdown
- Clean up temp files on cancellation
This commit is contained in:
2025-12-27 19:31:57 +01:00
parent 778d16b21a
commit 08f816a954
14 changed files with 145 additions and 900 deletions

View File

@@ -5,6 +5,30 @@ from typing import Any, Callable, Dict, List, Optional
class Loader(ABC):
"""Abstract base class for anime data loaders/providers."""
@abstractmethod
def request_cancel(self) -> None:
"""Request cancellation of any ongoing download.
Sets an internal flag that downloads should check periodically
and abort if set. This enables graceful shutdown.
"""
@abstractmethod
def reset_cancel(self) -> None:
"""Reset the cancellation flag.
Should be called before starting a new download to ensure
it's not immediately cancelled.
"""
@abstractmethod
def is_cancelled(self) -> bool:
"""Check if cancellation has been requested.
Returns:
bool: True if cancellation was requested
"""
@abstractmethod
def search(self, word: str) -> List[Dict[str, Any]]:
"""Search for anime series by name.