cleaned up cli

This commit is contained in:
Hellow2 2023-04-05 10:12:02 +02:00
parent 0c8953ed67
commit ec621ddc1f
2 changed files with 11 additions and 6 deletions

View File

@ -45,7 +45,7 @@ EXIT_COMMANDS = {
def cli(genre: str = None): def cli(genre: str = None, download_all: bool = False):
def get_existing_genre() -> List[str]: def get_existing_genre() -> List[str]:
""" """
gets the name of all subdirectories of shared.MUSIC_DIR, gets the name of all subdirectories of shared.MUSIC_DIR,
@ -89,12 +89,15 @@ def cli(genre: str = None):
if verification in agree_inputs: if verification in agree_inputs:
return new_genre return new_genre
def next_search(_search: pages.Search, query: str, genre: str) -> bool: def next_search(_search: pages.Search, query: str) -> bool:
""" """
:param _search: :param _search:
:param query: :param query:
:return exit in the next step: :return exit in the next step:
""" """
nonlocal genre
nonlocal download_all
query: str = query.strip() query: str = query.strip()
parsed: str = query.lower() parsed: str = query.lower()
@ -112,7 +115,7 @@ def cli(genre: str = None):
return False return False
if parsed in DOWNLOAD_COMMANDS: if parsed in DOWNLOAD_COMMANDS:
r = _search.download_chosen(genre=genre) r = _search.download_chosen(genre=genre, download_all=download_all)
print() print()
print(r) print(r)
@ -138,6 +141,7 @@ def cli(genre: str = None):
if genre is None: if genre is None:
genre = get_genre() genre = get_genre()
print() print()
print(get_random_message()) print(get_random_message())
print() print()
print(f"Downloading to: \"{genre}\"") print(f"Downloading to: \"{genre}\"")
@ -146,9 +150,10 @@ def cli(genre: str = None):
search = pages.Search() search = pages.Search()
while True: while True:
if next_search(search, input(">> "), genre): if next_search(search, input(">> "), genre, download_all):
break break
print(search) print(search)
print() print()
print(get_random_message()) print(get_random_message())
print("Have fun with your music. :3")

View File

@ -130,7 +130,7 @@ class Search(Download):
return True return True
def download_chosen(self, genre: str = None, **kwargs) -> DownloadResult: def download_chosen(self, genre: str = None, download_all: bool = False, **kwargs) -> DownloadResult:
if self._current_option._derive_from is None: if self._current_option._derive_from is None:
return DownloadResult(error_message="No option has been chosen yet.") return DownloadResult(error_message="No option has been chosen yet.")
@ -139,7 +139,7 @@ class Search(Download):
page = self._get_page_from_source(source=source) page = self._get_page_from_source(source=source)
if page in self.audio_pages: if page in self.audio_pages:
return page.download(music_object=self._current_option._derive_from, genre=genre, **kwargs) return page.download(music_object=self._current_option._derive_from, genre=genre, download_all=download_all, **kwargs)
return DownloadResult(error_message=f"Didn't find a source for {self._current_option._derive_from.option_string}.") return DownloadResult(error_message=f"Didn't find a source for {self._current_option._derive_from.option_string}.")