diff --git a/backup.py b/backup.py index 2434890..3f8e7ee 100644 --- a/backup.py +++ b/backup.py @@ -27,28 +27,28 @@ if __name__ == '__main__': logger.addHandler(stream_handler) - try: + # try: - network = Network(NetworkUser(os.environ['SPOTCLIENT'], - os.environ['SPOTSECRET'], - os.environ['SPOTREFRESH'])) - network.user.refresh_access_token() - playlists = network.get_user_playlists() + network = Network(NetworkUser(os.environ['SPOTCLIENT'], + os.environ['SPOTSECRET'], + os.environ['SPOTREFRESH'])) + network.user.refresh_access_token() + playlists = network.get_user_playlists() - for playlist in playlists: - playlist.tracks = network.get_playlist_tracks(playlist.uri) + for playlist in playlists: + playlist.tracks = network.get_playlist_tracks(playlist.uri) - path = sys.argv[1] + path = sys.argv[1] - datepath = str(datetime.datetime.now()).split(' ')[0].replace('-', '/') + datepath = str(datetime.datetime.now()).split(' ')[0].replace('-', '/') - totalpath = os.path.join(path, datepath) - pathdir = os.path.dirname(totalpath) - if not os.path.exists(totalpath): - os.makedirs(totalpath) + totalpath = os.path.join(path, datepath) + pathdir = os.path.dirname(totalpath) + if not os.path.exists(totalpath): + os.makedirs(totalpath) - for play in playlists: - csvwrite.export_playlist(play, totalpath) + for play in playlists: + csvwrite.export_playlist(play, totalpath) - except Exception as e: - logger.exception(f'exception occured') + # except Exception as e: + # logger.exception(f'exception occured') diff --git a/spotframework/net/network.py b/spotframework/net/network.py index b20c695..c24919c 100644 --- a/spotframework/net/network.py +++ b/spotframework/net/network.py @@ -284,7 +284,10 @@ class Network: playlists = self.get_playlists() - if playlists: + if self.user.username is None: + self.user.refresh_info() + + if playlists is not None: return list(filter(lambda x: x.owner.username == self.user.username, playlists)) else: logger.error('no playlists returned to filter')