added direct download argument

This commit is contained in:
Hellow 2023-04-12 13:13:02 +02:00
parent 4778a36275
commit 6d78f70e5f
2 changed files with 31 additions and 5 deletions

View File

@ -51,7 +51,13 @@ def print_cute_message():
print(message) print(message)
def cli(genre: str = None, download_all: bool = False): def exit_message():
print()
print_cute_message()
print("Have fun with your music. :3")
def cli(genre: str = None, download_all: bool = False, direct_download_url: str = None):
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,
@ -156,11 +162,22 @@ def cli(genre: str = None, download_all: bool = False):
search = pages.Search() search = pages.Search()
# directly download url
if direct_download_url is not None:
if search.search_url(direct_download_url):
r = search.download_chosen(genre=genre, download_all=download_all)
print()
print(r)
print()
else:
print(f"Sorry, could not download the url: {direct_download_url}")
exit_message()
return
while True: while True:
if next_search(search, input(">> ")): if next_search(search, input(">> ")):
break break
print(search) print(search)
print() exit_message()
print_cute_message()
print("Have fun with your music. :3")

View File

@ -34,6 +34,11 @@ if __name__ == "__main__":
"For example weird compilations from musify." "For example weird compilations from musify."
) )
parser.add_argument(
'-u', '--url',
help="Downloads the content of given url."
)
arguments = parser.parse_args() arguments = parser.parse_args()
if arguments.verbose or arguments.test: if arguments.verbose or arguments.test:
@ -46,4 +51,8 @@ if __name__ == "__main__":
if arguments.test: if arguments.test:
genre = "test" genre = "test"
music_kraken.cli(genre=genre, download_all=arguments.all) music_kraken.cli(
genre=genre,
download_all=arguments.all,
direct_download_url=arguments.url
)