diff --git a/python_aternos/atclient.py b/python_aternos/atclient.py index e38d6fc..e45358e 100644 --- a/python_aternos/atclient.py +++ b/python_aternos/atclient.py @@ -74,20 +74,22 @@ class Client: return a valid session cookie """ - atconn = AternosConnect() - - if len(custom_args) > 0: - atconn.add_args(**custom_args) - filename = cls.session_file( username, sessions_dir ) try: - return cls.restore_session(filename) + return cls.restore_session( + filename, **custom_args + ) except (OSError, CredentialsError): pass + atconn = AternosConnect() + + if len(custom_args) > 0: + atconn.add_args(**custom_args) + atconn.parse_token() atconn.generate_sec() diff --git a/python_aternos/atconnect.py b/python_aternos/atconnect.py index 34d0f2b..d658277 100644 --- a/python_aternos/atconnect.py +++ b/python_aternos/atconnect.py @@ -37,16 +37,31 @@ class AternosConnect: def add_args(self, **kwargs) -> None: - """Pass arguments to - CloudScarper session object __init__ + """Pass arguments to CloudScarper + session object __init__ + if kwargs is not empty Args: **kwargs: Keyword arguments """ + if len(kwargs) < 1: + logging.debug('**kwargs is empty') + return + + logging.debug('New args for CloudScraper: %s', kwargs) self.cf_init = partial(CloudScraper, **kwargs) self.refresh_session() + def clear_args(self) -> None: + + """Clear CloudScarper object __init__ arguments + which was set using add_args method""" + + logging.debug('Creating session object with no keywords') + self.cf_init = partial(CloudScraper) + self.refresh_session() + def refresh_session(self) -> None: """Creates a new CloudScraper