26 lines
763 B
Python
26 lines
763 B
Python
import os
|
|
|
|
|
|
def download_playlist(playlist: dict, playlist_root: str, file_type: str) -> None:
|
|
print(f"Downloading playlist {playlist['name']}")
|
|
|
|
# create playlist root, if not done yet
|
|
try:
|
|
os.mkdir(playlist_root)
|
|
except FileExistsError:
|
|
pass
|
|
os.chdir(playlist_root)
|
|
|
|
# create playlist folder if not don yet
|
|
playlist_dir = os.path.join(playlist_root, playlist["name"])
|
|
try:
|
|
os.mkdir(playlist_dir)
|
|
print(f"Playlist folder for {playlist['name']} created")
|
|
except FileExistsError:
|
|
print(f"Playlist folder for {playlist['name']} already created")
|
|
|
|
os.chdir(playlist_dir)
|
|
|
|
command = f"spotdl {playlist['external_urls']['spotify']} --output-format {file_type}"
|
|
os.system(command)
|