Skip to content

Commit

Permalink
Clear Terminal after entry selection and after download ends (#9)
Browse files Browse the repository at this point in the history
* Clear the Terminal after entry selection and after download ends (Closes #8)
  • Loading branch information
johnvictorfs committed Nov 17, 2019
1 parent ad284fc commit d9b0423
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions nyaacli/nyaa_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import inquirer

from nyaacli.colors import red, yellow, green, PromptTheme
from nyaacli.utils import clear_screen


def get_file_extension(path: str) -> str:
Expand Down Expand Up @@ -150,6 +151,8 @@ def search_torrent(search: str, episode: Optional[int] = None, dub: bool = False

answer = inquirer.prompt(questions, theme=PromptTheme())

clear_screen()

index_choice = answer['entry'] - 1

entry_choice = entries[index_choice]
Expand Down
5 changes: 4 additions & 1 deletion nyaacli/torrenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import libtorrent

from nyaacli.colors import red, green
from nyaacli.utils import clear_screen


def download_torrent(filename: str, result_filename: str = None, show_progress: bool = True, base_path: str = 'Anime'):
Expand Down Expand Up @@ -55,7 +56,9 @@ def download_torrent(filename: str, result_filename: str = None, show_progress:

os.rename(old_name, new_name)

print(f'Finished download, at: \'{green(new_name)}\' ')
clear_screen()

print(f'Finished download at: \'{green(new_name)}\' ')


if __name__ == '__main__':
Expand Down
9 changes: 9 additions & 0 deletions nyaacli/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os


def clear_screen():
"""
Runs either 'cls' or 'clear' on the Terminal, 'cls' to clear Terminal on windows,
which will ignore the rest of the command, and 'clear' to clear on Linux/Mac OS
"""
os.system('cls||clear')
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nyaacli"
version = "0.1.2"
version = "0.1.3"
description = "A CLI for downloading Anime from https://nyaa.si"
authors = ["John Victor <johnvictorfs@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit d9b0423

Please sign in to comment.