From 913c88e65c1e2da87ff83089cbadb1113af7f77e Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Sun, 10 Nov 2024 12:41:42 +0100 Subject: [PATCH] If login fails `token.json` will be removed, so the user can have a fresh start. Fixes #197 --- tidal_dl_ng/config.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tidal_dl_ng/config.py b/tidal_dl_ng/config.py index 715b7d3..a3ab809 100644 --- a/tidal_dl_ng/config.py +++ b/tidal_dl_ng/config.py @@ -125,8 +125,16 @@ class Tidal(BaseConfig, metaclass=SingletonMeta): self.data.expiry_time, is_pkce=do_pkce, ) - except HTTPError: + except (HTTPError, JSONDecodeError): result = False + # Remove token file. Probably corrupt or invalid. + if os.path.exists(self.file_path): + os.remove(self.file_path) + + print( + "Either there is something wrong with your credentials / account or some server problems on TIDALs " + "side. Anyway... Try to login again by re-starting this app." + ) return result