initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
from spotdl_connector import download_playlist
|
||||
from spotify_connection import get_playlists_by_user, get_playlist_info
|
||||
|
||||
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>")
|
||||
sys.exit(1)
|
||||
username = sys.argv[1]
|
||||
playlist_root = sys.argv[2]
|
||||
|
||||
# check for additional playlists
|
||||
if os.path.isfile(ADDITIONAL_PLAYLIST_FILE):
|
||||
with open(ADDITIONAL_PLAYLIST_FILE, "r") as pl_file:
|
||||
additional_playlists_raw = pl_file.readlines()
|
||||
|
||||
additional_playlists = [get_playlist_info(pl_uri) for pl_uri in additional_playlists_raw]
|
||||
|
||||
else:
|
||||
additional_playlists = list()
|
||||
|
||||
user_playlists = get_playlists_by_user(username)
|
||||
playlists = user_playlists + additional_playlists
|
||||
|
||||
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]
|
||||
|
||||
print("Done.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user