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)
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]:
"""
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()
# 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:
if next_search(search, input(">> ")):
break
print(search)
print()
print_cute_message()
print("Have fun with your music. :3")
exit_message()

View File

@ -34,6 +34,11 @@ if __name__ == "__main__":
"For example weird compilations from musify."
)
parser.add_argument(
'-u', '--url',
help="Downloads the content of given url."
)
arguments = parser.parse_args()
if arguments.verbose or arguments.test:
@ -46,4 +51,8 @@ if __name__ == "__main__":
if arguments.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
)