small changes

This commit is contained in:
2022-09-12 23:49:34 +02:00
parent a76f5cec0e
commit 8172768bdf
2 changed files with 9 additions and 4 deletions
+7 -2
View File
@@ -10,11 +10,16 @@ ADDITIONAL_PLAYLIST_FILE = "additional_playlists.txt"
def main() -> None:
# check for parameters
if len(sys.argv) < 3:
print("Usage: python playlists_downloader.py <username> <path_to_playlist_root>")
print("Usage: python playlists_downloader.py <username> <path_to_playlist_root> [file_type]")
sys.exit(1)
username = sys.argv[1]
playlist_root = sys.argv[2]
if len(sys.argv) < 4:
file_type = sys.argv[3]
else:
file_type = "mp3"
# check for additional playlists
if os.path.isfile(ADDITIONAL_PLAYLIST_FILE):
with open(ADDITIONAL_PLAYLIST_FILE, "r") as pl_file:
@@ -31,7 +36,7 @@ def main() -> None:
print(f"Downloading {len(user_playlists)} public playlist(s) by {username}")
print(f"Downloading {len(additional_playlists)} additional playlist(s)")
print(f"Root for playlist folders: {playlist_root}")
[download_playlist(pl, playlist_root) for pl in playlists]
[download_playlist(pl, playlist_root, file_type) for pl in playlists]
print("Done.")
+2 -2
View File
@@ -1,7 +1,7 @@
import os
def download_playlist(playlist: dict, playlist_root: str) -> None:
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
@@ -21,5 +21,5 @@ def download_playlist(playlist: dict, playlist_root: str) -> None:
os.chdir(playlist_dir)
command = f"spotdl {playlist['external_urls']['spotify']}"
command = f"spotdl {playlist['external_urls']['spotify']} --output-format {file_type}"
os.system(command)