diff --git a/xactfetch.py b/xactfetch.py index 5c70326..271db71 100644 --- a/xactfetch.py +++ b/xactfetch.py @@ -206,7 +206,6 @@ def download_chase( page: Page, end_date: datetime.date, token: str, importer: FireflyImporter ) -> bool: with Chase(page) as c, ntfyerror('Chase', page) as r: - c.login() key = ACCOUNTS['chase'] try: start_date = get_last_transaction_date(key, token) @@ -222,6 +221,7 @@ def download_chase( start_date, ) return True + c.login() csv = c.download_transactions(start_date, end_date) log.info('Importing transactions from Chase into Firefly III') c.firefly_import(csv, key, importer) @@ -237,7 +237,6 @@ def download_commerce( log.info('Downloading transaction lists from Commerce Bank') csvs = [] with CommerceBank(page) as c, ntfyerror('Commerce Bank', page) as r: - c.login() for name, key in ACCOUNTS['commerce'].items(): try: start_date = get_last_transaction_date(key, token) @@ -260,6 +259,7 @@ def download_commerce( start_date, name, ) + c.login() c.open_account(name) csvs.append((key, c.download_transactions(start_date, end_date))) log.info('Importing transactions from Commerce Bank into Firefly III') @@ -382,6 +382,8 @@ class CommerceBank: self.logout() def login(self) -> None: + if self._logged_in: + return log.debug('Navigating to %s', self.URL) self.page.goto(self.URL) password = rbw_get(self.vault_item, self.vault_folder, self.username) @@ -567,6 +569,8 @@ class Chase: log.info('Successfully saved cookies to %s', self.saved_cookies) def login(self) -> None: + if self._logged_in: + return log.debug('Navigating to %s', self.URL) self.page.goto(self.URL) self.page.wait_for_load_state()