mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 15:50:01 -08:00
feat(anilist-download-command): add previews
This commit is contained in:
@@ -106,7 +106,7 @@ if TYPE_CHECKING:
|
||||
)
|
||||
@click.option(
|
||||
"--yes",
|
||||
"-y",
|
||||
"-Y",
|
||||
is_flag=True,
|
||||
help="Automatically download from all found anime without prompting for selection.",
|
||||
)
|
||||
@@ -191,10 +191,26 @@ def download(config: AppConfig, **options: "Unpack[DownloadOptions]"):
|
||||
(item.title.english or item.title.romaji or f"ID: {item.id}"): item
|
||||
for item in search_result.media
|
||||
}
|
||||
selected_titles = selector.choose_multiple(
|
||||
"Select anime to download (use TAB to select, ENTER to confirm)",
|
||||
list(choice_map.keys()),
|
||||
)
|
||||
preview_command = None
|
||||
if config.general.preview != "none":
|
||||
from ....utils.preview import create_preview_context
|
||||
|
||||
with create_preview_context() as preview_ctx:
|
||||
preview_command = preview_ctx.get_anime_preview(
|
||||
list(choice_map.values()),
|
||||
list(choice_map.keys()),
|
||||
config,
|
||||
)
|
||||
selected_titles = selector.choose_multiple(
|
||||
"Select anime to download",
|
||||
list(choice_map.keys()),
|
||||
preview=preview_command,
|
||||
)
|
||||
else:
|
||||
selected_titles = selector.choose_multiple(
|
||||
"Select anime to download",
|
||||
list(choice_map.keys()),
|
||||
)
|
||||
if not selected_titles:
|
||||
feedback.warning("No anime selected. Aborting download.")
|
||||
return
|
||||
|
||||
@@ -35,9 +35,7 @@ class BaseSelector(ABC):
|
||||
self,
|
||||
prompt: str,
|
||||
choices: List[str],
|
||||
*,
|
||||
preview: Optional[str] = None,
|
||||
header: Optional[str] = None,
|
||||
) -> List[str]:
|
||||
"""
|
||||
Prompts the user to choose multiple items from a list.
|
||||
@@ -61,7 +59,6 @@ class BaseSelector(ABC):
|
||||
f"{prompt} (Select multiple, empty to finish)",
|
||||
remaining_choices + ["[DONE] Finish selection"],
|
||||
preview=preview,
|
||||
header=header,
|
||||
)
|
||||
|
||||
if not choice or choice == "[DONE] Finish selection":
|
||||
|
||||
@@ -53,7 +53,7 @@ class FzfSelector(BaseSelector):
|
||||
return None
|
||||
return result.stdout.strip()
|
||||
|
||||
def choose_multiple(self, prompt, choices, *, preview=None, header=None):
|
||||
def choose_multiple(self, prompt, choices, preview=None):
|
||||
"""Enhanced multi-selection using fzf's --multi flag."""
|
||||
fzf_input = "\n".join(choices)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user