small changes
This commit is contained in:
@@ -10,11 +10,16 @@ ADDITIONAL_PLAYLIST_FILE = "additional_playlists.txt"
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
# check for parameters
|
# check for parameters
|
||||||
if len(sys.argv) < 3:
|
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)
|
sys.exit(1)
|
||||||
username = sys.argv[1]
|
username = sys.argv[1]
|
||||||
playlist_root = sys.argv[2]
|
playlist_root = sys.argv[2]
|
||||||
|
|
||||||
|
if len(sys.argv) < 4:
|
||||||
|
file_type = sys.argv[3]
|
||||||
|
else:
|
||||||
|
file_type = "mp3"
|
||||||
|
|
||||||
# check for additional playlists
|
# check for additional playlists
|
||||||
if os.path.isfile(ADDITIONAL_PLAYLIST_FILE):
|
if os.path.isfile(ADDITIONAL_PLAYLIST_FILE):
|
||||||
with open(ADDITIONAL_PLAYLIST_FILE, "r") as pl_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(user_playlists)} public playlist(s) by {username}")
|
||||||
print(f"Downloading {len(additional_playlists)} additional playlist(s)")
|
print(f"Downloading {len(additional_playlists)} additional playlist(s)")
|
||||||
print(f"Root for playlist folders: {playlist_root}")
|
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.")
|
print("Done.")
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import os
|
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']}")
|
print(f"Downloading playlist {playlist['name']}")
|
||||||
|
|
||||||
# create playlist root, if not done yet
|
# create playlist root, if not done yet
|
||||||
@@ -21,5 +21,5 @@ def download_playlist(playlist: dict, playlist_root: str) -> None:
|
|||||||
|
|
||||||
os.chdir(playlist_dir)
|
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)
|
os.system(command)
|
||||||
|
|||||||
Reference in New Issue
Block a user