Added download_artist_albums

Added a function to be called in client if
artist_id_str is not None;
download_artist_albums(artist_id_str) that
uses the get_artist_album function to get the
artist's album id's and then downloads each one
with the download_album function.

Also modified get_artist_album function to return
a list of album ids instead of a list of tuples
of album ids and names.
This commit is contained in:
yiannisha 2021-10-21 23:27:02 +03:00
parent 92090512d0
commit 126ebe2046

View File

@ -127,6 +127,8 @@ def client():
if track_id_str is not None:
download_track(track_id_str)
elif artist_id_str is not None:
download_artist_albums(artist_id_str)
elif album_id_str is not None:
download_album(album_id_str)
elif playlist_id_str is not None:
@ -146,6 +148,8 @@ def client():
if track_id_str is not None:
download_track(track_id_str)
elif artist_id_str is not None:
download_artist_albums(artist_id_str)
elif album_id_str is not None:
download_album(album_id_str)
elif playlist_id_str is not None:
@ -604,6 +608,12 @@ def download_album(album):
download_track(track['id'], artist + " - " + album_name + "/")
print("\n")
def download_artist_albums(artist):
""" Downloads albums of an artist """
token = SESSION.tokens().get("user-read-email")
albums = get_artist_albums(token, artist)
for name, album_id in albums:
download_album(album_id)
def download_from_user_playlist():
""" Downloads songs from users playlist """