Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear Terminal after entry selection and after download ends #9

Merged
merged 3 commits into from
Nov 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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