Skip to content

Commit

Permalink
fix: when executin custom script, let spinner not overwrite any inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sdaqo committed Dec 23, 2024
1 parent 64487b7 commit 67d9150
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/src/anipy_cli/download_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def download_ep(
get_download_path(anime, stream, parent_directory=self.dl_path),
container=config.remux_to,
ffmpeg=self.options.ffmpeg or config.ffmpeg_hls,
post_dl_cb=get_post_download_scripts_hook(self.mode, anime)
post_dl_cb=get_post_download_scripts_hook(self.mode, anime, spinner)
)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion cli/src/anipy_cli/menus/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def error_display(message: str):
get_download_path(self.anime, self.stream),
container=config.remux_to,
ffmpeg=self.options.ffmpeg or config.ffmpeg_hls,
post_dl_cb=get_post_download_scripts_hook("default", self.anime)
post_dl_cb=get_post_download_scripts_hook("default", self.anime, s)
)

if Config().auto_open_dl_defaultcli:
Expand Down
4 changes: 3 additions & 1 deletion cli/src/anipy_cli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ def get_download_path(

return download_folder / anime_name / filename

def get_post_download_scripts_hook(mode: str, anime: "Anime") -> PostDownloadCallback:
def get_post_download_scripts_hook(mode: str, anime: "Anime", spinner: DotSpinner) -> PostDownloadCallback:
config = Config()
scripts = config.post_download_scripts[mode]
timeout = config.post_download_scripts["timeout"]

def hook(path: Path, stream: "ProviderStream"):
spinner.hide()
arguments = [
str(path), anime.name,
str(stream.episode), anime.provider.NAME,
Expand All @@ -135,6 +136,7 @@ def hook(path: Path, stream: "ProviderStream"):
for s in scripts:
sub_proc = sp.Popen([s, *arguments])
sub_proc.wait(timeout) # type: ignore
spinner.show()

return hook

Expand Down

0 comments on commit 67d9150

Please sign in to comment.