Show more progress updates when starting up script
This commit is contained in:
@@ -13,7 +13,9 @@ def main():
|
|||||||
|
|
||||||
with open(args.config, 'r') as f:
|
with open(args.config, 'r') as f:
|
||||||
config = yaml.safe_load(f)
|
config = yaml.safe_load(f)
|
||||||
|
print("Opening Spotify session")
|
||||||
spotify_session = _auth.open_spotify_session(config['spotify'])
|
spotify_session = _auth.open_spotify_session(config['spotify'])
|
||||||
|
print("Opening Tidal session")
|
||||||
tidal_session = _auth.open_tidal_session()
|
tidal_session = _auth.open_tidal_session()
|
||||||
if not tidal_session.check_login():
|
if not tidal_session.check_login():
|
||||||
sys.exit("Could not connect to Tidal")
|
sys.exit("Could not connect to Tidal")
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ def tidal_search(spotify_track_and_cache, tidal_session: tidalapi.Session) -> ti
|
|||||||
|
|
||||||
def get_tidal_playlists_dict(tidal_session: tidalapi.Session) -> Mapping[str, tidalapi.Playlist]:
|
def get_tidal_playlists_dict(tidal_session: tidalapi.Session) -> Mapping[str, tidalapi.Playlist]:
|
||||||
# a dictionary of name --> playlist
|
# a dictionary of name --> playlist
|
||||||
|
print("Loading Tidal playlists... This may take some time.")
|
||||||
tidal_playlists = tidal_session.user.playlists()
|
tidal_playlists = tidal_session.user.playlists()
|
||||||
output = {}
|
output = {}
|
||||||
for playlist in tidal_playlists:
|
for playlist in tidal_playlists:
|
||||||
@@ -275,17 +276,21 @@ def get_user_playlist_mappings(spotify_session: spotipy.Spotify, tidal_session:
|
|||||||
def get_playlists_from_spotify(spotify_session: spotipy.Spotify, config):
|
def get_playlists_from_spotify(spotify_session: spotipy.Spotify, config):
|
||||||
# get all the user playlists from the Spotify account
|
# get all the user playlists from the Spotify account
|
||||||
playlists = []
|
playlists = []
|
||||||
spotify_results = spotify_session.user_playlists(config['spotify']['username'])
|
with tqdm(total=1.0) as pbar:
|
||||||
exclude_list = set([x.split(':')[-1] for x in config.get('excluded_playlists', [])])
|
pbar.set_description("Loading Spotify playlists")
|
||||||
while True:
|
spotify_results = spotify_session.user_playlists(config['spotify']['username'])
|
||||||
for spotify_playlist in spotify_results['items']:
|
total = spotify_results['total']
|
||||||
if spotify_playlist['owner']['id'] == config['spotify']['username'] and not spotify_playlist['id'] in exclude_list:
|
exclude_list = set([x.split(':')[-1] for x in config.get('excluded_playlists', [])])
|
||||||
playlists.append(spotify_playlist)
|
while True:
|
||||||
# move to the next page of results if there are still playlists remaining
|
pbar.update(len(spotify_results['items'])/total)
|
||||||
if spotify_results['next']:
|
for spotify_playlist in spotify_results['items']:
|
||||||
spotify_results = spotify_session.next(spotify_results)
|
if spotify_playlist['owner']['id'] == config['spotify']['username'] and not spotify_playlist['id'] in exclude_list:
|
||||||
else:
|
playlists.append(spotify_playlist)
|
||||||
break
|
# move to the next page of results if there are still playlists remaining
|
||||||
|
if spotify_results['next']:
|
||||||
|
spotify_results = spotify_session.next(spotify_results)
|
||||||
|
else:
|
||||||
|
break
|
||||||
return playlists
|
return playlists
|
||||||
|
|
||||||
def get_playlists_from_config(config):
|
def get_playlists_from_config(config):
|
||||||
|
|||||||
Reference in New Issue
Block a user