From 214b04d7cc0ee74b5539d9f01a6de507cdd9ed83 Mon Sep 17 00:00:00 2001 From: Hellow2 Date: Thu, 30 Mar 2023 10:07:42 +0200 Subject: [PATCH] implemented new cli --- src/actual_donwload.py | 24 ++++++++++++++++++- .../pages/download_center/search.py | 5 +++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/actual_donwload.py b/src/actual_donwload.py index 5a715b9..7885963 100644 --- a/src/actual_donwload.py +++ b/src/actual_donwload.py @@ -2,10 +2,32 @@ from music_kraken import pages def cli(): + def next_search(search: pages.Search, query: str): + query: str = query.strip() + parsed: str = query.lower() + + if parsed == ".": + return + if parsed == "..": + search.goto_previous() + return + + if parsed.isdigit(): + search.choose_index(int(parsed)) + return + + page = search.get_page_from_query(parsed) + if page is not None: + search.choose_page(page) + return + + # if everything else is not valid search + search.search(query) + search = pages.Search() while True: - search.next_input(input(">> ")) + next_search(search, input(">> ")) print(search) diff --git a/src/music_kraken/pages/download_center/search.py b/src/music_kraken/pages/download_center/search.py index 82cc18b..73eaac5 100644 --- a/src/music_kraken/pages/download_center/search.py +++ b/src/music_kraken/pages/download_center/search.py @@ -176,4 +176,7 @@ class Search(Download): mpo[page] = music_object.options def goto_previous(self): - self._current_option = self._previous_options + try: + self._current_option = self._previous_options + except IndexError: + pass