From f0aaa8147af3f9a45e9bda14276188f70feddba9 Mon Sep 17 00:00:00 2001 From: victordlp8 Date: Sat, 29 Oct 2022 00:37:46 +0200 Subject: [PATCH] Added some error handling --- spotifyVisualizer.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spotifyVisualizer.py b/spotifyVisualizer.py index fb14f0a..3a64045 100644 --- a/spotifyVisualizer.py +++ b/spotifyVisualizer.py @@ -24,8 +24,15 @@ def main(): DATE_FORMAT = 'Week %W of %Y' paths = Paths() - fileList = [f for f in os.listdir( - paths.data) if os.path.isfile(os.path.join(paths.data, f))] + if os.path.exists(paths.data): + fileList = [f for f in os.listdir( + paths.data) if os.path.isfile(os.path.join(paths.data, f))] + if len(fileList) == 0: + print('[ERROR] Unable to find StreamingHistory files.') + exit() + else: + print('[ERROR] Please make sure the directory \'data\' exists.') + exit() songs = [] for file in fileList: